summaryrefslogtreecommitdiff
path: root/scripts/qapi-visit.py
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-11-18 01:52:36 -0700
committerMarkus Armbruster <armbru@redhat.com>2015-12-17 08:21:26 +0100
commitda34a9bd999d1be13954c699bbae0295cdaa3200 (patch)
treeb29af5eb5a26b17fdf4a6910f3e09bb370642ace /scripts/qapi-visit.py
parenta8c40fa2d667e585382080db36ac44e216b37a1c (diff)
downloadqemu-da34a9bd999d1be13954c699bbae0295cdaa3200.tar.gz
qemu-da34a9bd999d1be13954c699bbae0295cdaa3200.tar.bz2
qemu-da34a9bd999d1be13954c699bbae0295cdaa3200.zip
qapi: Track simple union tag in object.local_members
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(). 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 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 <eblake@redhat.com> Message-Id: <1447836791-369-2-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts/qapi-visit.py')
-rw-r--r--scripts/qapi-visit.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 3ef5c16a66..94cd11335e 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -364,7 +364,10 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
def visit_object_type(self, name, info, base, members, variants):
self.decl += gen_visit_decl(name)
if variants:
- assert not members # not implemented
+ if members:
+ # Members other than variants.tag_member not implemented
+ assert len(members) == 1
+ assert members[0] == variants.tag_member
self.defn += gen_visit_union(name, base, variants)
else:
self.defn += gen_visit_struct(name, base, members)