[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 35/46] qapi-visit: Remove redundant functions
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v5 35/46] qapi-visit: Remove redundant functions for flat union base |
Date: |
Wed, 23 Sep 2015 14:55:43 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 09/21/2015 03:57 PM, Eric Blake wrote:
> The code for visiting the base class of a child struct created
> visit_type_Base_fields(); the code for visiting the base class
> of a flat union created visit_type_Union_fields(). If the same
> type is shared between a struct and a union, the two functions
> differed only by whether they visited the discriminator used by
> the union. But if the base class always visits all its fields,
> then we don't need to revisit the discriminator specially for
> a union. By consistently visiting the base class fields under
> the name of the base class, we can eliminate some redundant
> code.
>
> Now that gen_visit_struct_fields() can potentially collect more
> than one function into 'ret', a regular expression searching for
> whether a label was used may hit a false positive within the
> body of the first function. But using a regex was overkill,
> since we can easily determine when we jumped to a label.
>
> visit_type_%(c_type)s(v, &(*obj)->%(c_name)s, "%(name)s", &err);
> - if (err) {
> - goto out_obj;
> - }
> - switch ((*obj)->%(c_name)s) {
> ''',
> - c_type=variants.tag_member.type.c_name(),
> - c_name=c_name(tag_key), name=tag_key)
> + c_type=variants.tag_member.type.c_name(),
> + c_name=c_name(tag_key), name=tag_key)
> + ret += mcgen('''
> + if (err) {
> + goto out_obj;
> + }
> + switch ((*obj)->%(c_name)s) {
Rebase snafu - I botched the generated indentation within this mcgen()
by 4 spaces. Shouldn't affect a technical review, and I will fix it up
for v6.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v5 23/46] qapi: Remove dead visitor code, (continued)
- [Qemu-devel] [PATCH v5 23/46] qapi: Remove dead visitor code, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 27/46] qapi: Simplify visits of optional fields, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 25/46] qapi: Plug leaks in test-qmp-input-visitor, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 24/46] qapi: Document visitor interfaces, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 28/46] qapi: Rework deallocation of partial struct, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 29/46] qapi: Change visit_type_FOO() to no longer return partial objects, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 30/46] net: use Netdev instead of NetClientOptions in client init, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 33/46] vnc: hoist allocation of VncBasicInfo to callers, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 32/46] qapi: Hide tag_name data member of variants, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 35/46] qapi-visit: Remove redundant functions for flat union base, Eric Blake, 2015/09/21
- Re: [Qemu-devel] [PATCH v5 35/46] qapi-visit: Remove redundant functions for flat union base,
Eric Blake <=
- [Qemu-devel] [PATCH v5 34/46] qapi: Unbox base members, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 36/46] qapi: Avoid use of 'data' member of qapi unions, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 38/46] qapi: Drop useless 'data' member of unions, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 37/46] qapi: Forbid empty unions and useless alternates, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 39/46] qapi: Plumb in 'box' to qapi generator lower levels, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 41/46] qapi: Support boxed unions, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 40/46] qapi: Implement boxed structs for commands/events, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 42/46] qapi: support implicit structs in OptsVisitor, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 31/46] qapi: use 'type' in generated C code to match QMP union wire form, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 44/46] net: Use correct type for bool flag, Eric Blake, 2015/09/21