@@ -1015,7 +1015,7 @@ class QAPISchemaObjectTypeVariants(object):
assert tag_enum is None or isinstance(tag_enum, str)
for v in variants:
assert isinstance(v, QAPISchemaObjectTypeVariant)
- self.tag_name = tag_name
+ self._tag_name = tag_name
if tag_name: # flat union
assert not tag_enum
self.tag_member = None
@@ -1028,9 +1028,9 @@ class QAPISchemaObjectTypeVariants(object):
self.variants = variants
def check(self, schema, info, members, seen):
- if self.tag_name:
- self.tag_member = seen[c_name(self.tag_name)]
- assert self.tag_name == self.tag_member.name
+ if self._tag_name:
+ self.tag_member = seen[c_name(self._tag_name)]
+ assert self._tag_name == self.tag_member.name
elif self.tag_member:
self.tag_member.check(schema, info, members, seen)
typ = None
@@ -113,6 +113,7 @@ object UserDefFlatUnion2
case value2: UserDefB
case value3: UserDefA
object UserDefNativeListUnion
+ tag type
case integer: :obj-intList-wrapper
case s8: :obj-int8List-wrapper
case s16: :obj-int16List-wrapper
@@ -167,6 +168,7 @@ object __org.qemu_x-Struct
object __org.qemu_x-Struct2
member array: __org.qemu_x-Union1List optional=False
object __org.qemu_x-Union1
+ tag type
case __org.qemu_x-branch: :obj-str-wrapper
enum __org.qemu_x-Union1Kind ['__org.qemu_x-branch']
object __org.qemu_x-Union2
@@ -47,8 +47,8 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
@staticmethod
def _print_variants(variants):
if variants:
- if variants.tag_name:
- print ' tag %s' % variants.tag_name
+ if variants.tag_member:
+ print ' tag %s' % variants.tag_member.name
for v in variants.variants:
print ' case %s: %s' % (v.name, v.type.name)
@@ -2,5 +2,6 @@ object :empty
object :obj-int-wrapper
member data: int optional=False
object TestUnion
+ tag type
case data: :obj-int-wrapper
enum TestUnionKind ['data']
@@ -1,3 +1,4 @@
object :empty
object Union
+ tag type
enum UnionKind []
Clean up the only remaining external use of the tag_name field of QAPISchemaObjectTypeVariants, by explicitly listing the generated 'type' tag for simple unions in the testsuite. Since alternate types no longer use the tag_member field, we can now mark the tag_name field as private by adding a leading underscore to prevent any further use. Signed-off-by: Eric Blake <eblake@redhat.com> --- scripts/qapi.py | 8 ++++---- tests/qapi-schema/qapi-schema-test.out | 2 ++ tests/qapi-schema/test-qapi.py | 4 ++-- tests/qapi-schema/union-clash2.out | 1 + tests/qapi-schema/union-empty.out | 1 + 5 files changed, 10 insertions(+), 6 deletions(-)