[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v9 10/27] qapi: Track simple union tag in object
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v9 10/27] qapi: Track simple union tag in object.local_members |
Date: |
Wed, 04 Nov 2015 12:02:34 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eric Blake <address@hidden> writes:
> We were previously creating all unions with an empty list for
> local_members. However, it will make it easier to unify struct
> and union generation if we include the generated tag member in
> local_members. That way, we can have a common code pattern:
> visit the base (if any), visit the local members (if any), visit
> the variants (if any). The local_members of a flat union
> remains empty (because the discriminator is already visited as
> part of the base). Then, by visiting tag_member.check() during
> AlternateType.check(), we no longer need to call it during
> Variants.check().
Moving tag_member.check() could perhaps be a separate patch. But it's
okay as is.
> The various front end entities now exist as follows:
> struct: optional base, optional local_members, no variants
> simple union: no base, one-element local_members, variants with tag_member
> from local_members
> flat union: base, no local_members, variants with tag_member from base
> alternate: no base, no local_members, variants
Ultimately, I'd like a single object type. Then this becomes:
object: optional base, optional local_members,
optional variants with tag_member from base or local_members
alternate: only variants
In both cases, I view the tag member as belonging to the outer
container, not variants:
object stores it like any other member, and variants.tag_member
merely identifies the member that serves as tag
alternate doesn't store it member in self, but simply uses
self.variants.tag_member instead.
Perhaps QAPISchemaObjectTypeVariants should be inlined.
Just rambling, the commit message is fine as is.
> With the new local members, we require a bit of finesse to
> avoid assertions in the clients.
>
> No change to generated code.
>
> Signed-off-by: Eric Blake <address@hidden>
Patch looks good.
- [Qemu-devel] [PATCH v9 00/27] alternate layout (post-introspection cleanups, subset C), Eric Blake, 2015/11/04
- [Qemu-devel] [PATCH v9 07/27] qapi: More tests of input arrays, Eric Blake, 2015/11/04
- [Qemu-devel] [PATCH v9 05/27] qapi: More tests of alternate output, Eric Blake, 2015/11/04
- [Qemu-devel] [PATCH v9 06/27] qapi: Test failure in middle of array parse, Eric Blake, 2015/11/04
- [Qemu-devel] [PATCH v9 02/27] qapi: Strengthen test of TestStructList, Eric Blake, 2015/11/04
- [Qemu-devel] [PATCH v9 10/27] qapi: Track simple union tag in object.local_members, Eric Blake, 2015/11/04
- Re: [Qemu-devel] [PATCH v9 10/27] qapi: Track simple union tag in object.local_members,
Markus Armbruster <=
- [Qemu-devel] [PATCH v9 09/27] qapi-introspect: Document lack of sorting, Eric Blake, 2015/11/04
- [Qemu-devel] [PATCH v9 14/27] qapi: Fix up commit 7618b91's clash sanity checking change, Eric Blake, 2015/11/04
- [Qemu-devel] [PATCH v9 13/27] qapi: Drop obsolete tag value collision assertions, Eric Blake, 2015/11/04
- [Qemu-devel] [PATCH v9 03/27] qapi: Plug leaks in test-qmp-*, Eric Blake, 2015/11/04