mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-25 22:17:44 +00:00
qapi: Hide tag_name data member of variants
Clean up the only remaining external use of the tag_name field of QAPISchemaObjectTypeVariants, by explicitly listing the generated 'type' tag for all variants in the testsuite (you can still tell simple unions by the -wrapper types). Then we can mark the tag_name field as private by adding a leading underscore to prevent any further use. Backports commit da9cb19385fc66b2cb2584bbbbcbf50246d057e2 from qemu
This commit is contained in:
parent
febeea5f4b
commit
4b39eaae33
1 changed files with 4 additions and 4 deletions
|
@ -1099,7 +1099,7 @@ class QAPISchemaObjectTypeVariants(object):
|
||||||
assert len(variants) > 0
|
assert len(variants) > 0
|
||||||
for v in variants:
|
for v in variants:
|
||||||
assert isinstance(v, QAPISchemaObjectTypeVariant)
|
assert isinstance(v, QAPISchemaObjectTypeVariant)
|
||||||
self.tag_name = tag_name
|
self._tag_name = tag_name
|
||||||
self.tag_member = tag_member
|
self.tag_member = tag_member
|
||||||
self.variants = variants
|
self.variants = variants
|
||||||
|
|
||||||
|
@ -1109,8 +1109,8 @@ class QAPISchemaObjectTypeVariants(object):
|
||||||
|
|
||||||
def check(self, schema, seen):
|
def check(self, schema, seen):
|
||||||
if not self.tag_member: # flat union
|
if not self.tag_member: # flat union
|
||||||
self.tag_member = seen[c_name(self.tag_name)]
|
self.tag_member = seen[c_name(self._tag_name)]
|
||||||
assert self.tag_name == self.tag_member.name
|
assert self._tag_name == self.tag_member.name
|
||||||
assert isinstance(self.tag_member.type, QAPISchemaEnumType)
|
assert isinstance(self.tag_member.type, QAPISchemaEnumType)
|
||||||
for v in self.variants:
|
for v in self.variants:
|
||||||
v.check(schema)
|
v.check(schema)
|
||||||
|
@ -1150,7 +1150,7 @@ class QAPISchemaAlternateType(QAPISchemaType):
|
||||||
def __init__(self, name, info, variants):
|
def __init__(self, name, info, variants):
|
||||||
QAPISchemaType.__init__(self, name, info)
|
QAPISchemaType.__init__(self, name, info)
|
||||||
assert isinstance(variants, QAPISchemaObjectTypeVariants)
|
assert isinstance(variants, QAPISchemaObjectTypeVariants)
|
||||||
assert not variants.tag_name
|
assert variants.tag_member
|
||||||
variants.set_owner(name)
|
variants.set_owner(name)
|
||||||
variants.tag_member.set_owner(self.name)
|
variants.tag_member.set_owner(self.name)
|
||||||
self.variants = variants
|
self.variants = variants
|
||||||
|
|
Loading…
Reference in a new issue