[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/3] qapi-visit: Simplify how we visit common un
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 1/3] qapi-visit: Simplify how we visit common union members |
Date: |
Wed, 27 Jan 2016 14:48:24 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
On 01/27/2016 06:54 AM, Markus Armbruster wrote:
> For a simple union SU, gen_visit_union() generates a visit of its
> single tag member, like this:
>
> visit_type_SUKind(v, "type", &(*obj)->type, &err);
>
> For a flat union FU with base B, it generates a visit of its base
> fields:
>
> visit_type_B_fields(v, (B **)obj, &err);
>
> Instead, we can simply visit the common members using the same fields
> visit function we use for structs, generated with
> gen_visit_struct_fields(). This function visits the base if any, then
> the local members.
I like how you've split up my gen_struct/gen_union merge into a few more
steps. I'll be incorporating your patch into my v10 spin.
>
> For a simple union SU, visit_type_SU_fields() contains exactly the old
> tag member visit, because there is no base, and the tag member is the
> only member. For instance, the code generated for
> qapi-schema-test.json's UserDefNativeListUnion changes like this:
>
> @@ -740,6 +766,19 @@ out:
> error_propagate(errp, err);
> }
>
> +static void visit_type_UserDefNativeListUnion_fields(Visitor *v,
> UserDefNativeListUnion **obj, Error **errp)
I may try to rewrite the commit to pick a shorter example, though :)
>
> As you see, the generated code grows a bit, but in practice, it's lost
> in the noise: qapi-schema.json's qapi-visit.c gains roughly 1%.
>
> This simplification became possible with commit 441cbac "qapi-visit:
> Convert to QAPISchemaVisitor, fixing bugs". It's a step towards
> unifying gen_struct() and gen_union().
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> scripts/qapi-visit.py | 27 ++++-----------------------
> 1 file changed, 4 insertions(+), 23 deletions(-)
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v9 21/37] qapi: Document visitor interfaces, add assertions, (continued)
[Qemu-devel] [PATCH v9 26/37] qapi: Simplify excess input reporting in input visitors, Eric Blake, 2016/01/19
[Qemu-devel] [PATCH 0/3] qapi-visit: Unify struct and union visit, Markus Armbruster, 2016/01/27
[Qemu-devel] [PATCH 3/3] qapi-visit: Unify struct and union visit, Markus Armbruster, 2016/01/27
[Qemu-devel] [PATCH 2/3] qapi-visit: Clean up code generated around visit_end_union(), Markus Armbruster, 2016/01/27
Re: [Qemu-devel] [PATCH 2/3] qapi-visit: Clean up code generated around visit_end_union(), Eric Blake, 2016/01/27
Re: [Qemu-devel] [PATCH 2/3] qapi-visit: Clean up code generated around visit_end_union(), Markus Armbruster, 2016/01/27
[Qemu-devel] [PATCH v9 18/37] qapi: Drop unused error argument for list and implicit struct, Eric Blake, 2016/01/19
[Qemu-devel] [PATCH v9 17/37] qapi: Drop unused 'kind' for struct/enum visit, Eric Blake, 2016/01/19