qapi-visit: Honor prefix of discriminator enum
When we added support for a user-specified prefix for an enum
type (commit 351d36e
), we forgot to teach the qapi-visit code
to honor that prefix in the case of using a prefixed enum as
the discriminator for a flat union. While there is still some
on-list debate on whether we want to keep prefixes, we should
at least make it work as long as it is still part of the code
base.
Reported-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1455665965-27638-1-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
dd5e38b19d
commit
9d3524b39e
@ -293,7 +293,8 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
|
|||||||
case %(case)s:
|
case %(case)s:
|
||||||
''',
|
''',
|
||||||
case=c_enum_const(variants.tag_member.type.name,
|
case=c_enum_const(variants.tag_member.type.name,
|
||||||
var.name))
|
var.name,
|
||||||
|
variants.tag_member.type.prefix))
|
||||||
if simple_union_type:
|
if simple_union_type:
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
visit_type_%(c_type)s(v, "data", &(*obj)->u.%(c_name)s, &err);
|
visit_type_%(c_type)s(v, "data", &(*obj)->u.%(c_name)s, &err);
|
||||||
|
@ -73,14 +73,17 @@
|
|||||||
'base': 'UserDefZero',
|
'base': 'UserDefZero',
|
||||||
'data': { 'string': 'str', 'enum1': 'EnumOne' } }
|
'data': { 'string': 'str', 'enum1': 'EnumOne' } }
|
||||||
|
|
||||||
|
{ 'struct': 'UserDefUnionBase2',
|
||||||
|
'base': 'UserDefZero',
|
||||||
|
'data': { 'string': 'str', 'enum1': 'QEnumTwo' } }
|
||||||
|
|
||||||
# this variant of UserDefFlatUnion defaults to a union that uses fields with
|
# this variant of UserDefFlatUnion defaults to a union that uses fields with
|
||||||
# allocated types to test corner cases in the cleanup/dealloc visitor
|
# allocated types to test corner cases in the cleanup/dealloc visitor
|
||||||
{ 'union': 'UserDefFlatUnion2',
|
{ 'union': 'UserDefFlatUnion2',
|
||||||
'base': 'UserDefUnionBase',
|
'base': 'UserDefUnionBase2',
|
||||||
'discriminator': 'enum1',
|
'discriminator': 'enum1',
|
||||||
'data': { 'value1' : 'UserDefC', # intentional forward reference
|
'data': { 'value1' : 'UserDefC', # intentional forward reference
|
||||||
'value2' : 'UserDefB',
|
'value2' : 'UserDefB' } }
|
||||||
'value3' : 'UserDefA' } }
|
|
||||||
|
|
||||||
{ 'alternate': 'UserDefAlternate',
|
{ 'alternate': 'UserDefAlternate',
|
||||||
'data': { 'uda': 'UserDefA', 's': 'str', 'i': 'int' } }
|
'data': { 'uda': 'UserDefA', 's': 'str', 'i': 'int' } }
|
||||||
|
@ -121,11 +121,10 @@ object UserDefFlatUnion
|
|||||||
case value2: UserDefB
|
case value2: UserDefB
|
||||||
case value3: UserDefB
|
case value3: UserDefB
|
||||||
object UserDefFlatUnion2
|
object UserDefFlatUnion2
|
||||||
base UserDefUnionBase
|
base UserDefUnionBase2
|
||||||
tag enum1
|
tag enum1
|
||||||
case value1: UserDefC
|
case value1: UserDefC
|
||||||
case value2: UserDefB
|
case value2: UserDefB
|
||||||
case value3: UserDefA
|
|
||||||
object UserDefNativeListUnion
|
object UserDefNativeListUnion
|
||||||
member type: UserDefNativeListUnionKind optional=False
|
member type: UserDefNativeListUnionKind optional=False
|
||||||
case integer: :obj-intList-wrapper
|
case integer: :obj-intList-wrapper
|
||||||
@ -167,6 +166,10 @@ object UserDefUnionBase
|
|||||||
base UserDefZero
|
base UserDefZero
|
||||||
member string: str optional=False
|
member string: str optional=False
|
||||||
member enum1: EnumOne optional=False
|
member enum1: EnumOne optional=False
|
||||||
|
object UserDefUnionBase2
|
||||||
|
base UserDefZero
|
||||||
|
member string: str optional=False
|
||||||
|
member enum1: QEnumTwo optional=False
|
||||||
object UserDefZero
|
object UserDefZero
|
||||||
member integer: int optional=False
|
member integer: int optional=False
|
||||||
event __ORG.QEMU_X-EVENT __org.qemu_x-Struct
|
event __ORG.QEMU_X-EVENT __org.qemu_x-Struct
|
||||||
|
Loading…
Reference in New Issue
Block a user