qapi: Support downstream simple unions

Enhance the testsuite to cover downstream simple unions, including
when a union branch is a downstream name. Update the generator to
mangle the union names in the appropriate places.

Backports commit bb33729043ceda56b4068db13bdc17786ebd0ed0 from qemu
This commit is contained in:
Eric Blake 2018-02-19 15:05:08 -05:00 committed by Lioncash
parent 2d14039f98
commit a2119bd210
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 5 additions and 5 deletions

View file

@ -184,7 +184,7 @@ const int %(name)s_qtypes[QTYPE_MAX] = {
def generate_union(expr, meta):
name = expr[meta]
name = c_name(expr[meta])
typeinfo = expr['data']
base = expr.get('base')

View file

@ -256,9 +256,9 @@ def generate_visit_union(expr):
disc_type = enum_define['enum_name']
else:
# There will always be a discriminator in the C switch code, by default
# it is an enum type generated silently as "'%sKind' % (name)"
ret = generate_visit_enum('%sKind' % name, members.keys())
disc_type = '%sKind' % (name)
# it is an enum type generated silently
ret = generate_visit_enum(name + 'Kind', members.keys())
disc_type = c_name(name) + 'Kind'
if base:
assert discriminator
@ -282,7 +282,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s **obj, const char *name, Error **e
}
if (*obj) {
''',
name=name)
name=c_name(name))
if base:
ret += mcgen('''