mirror of
https://github.com/mii443/qemu.git
synced 2025-08-23 07:35:47 +00:00
qapi: Add #if conditions to generated code members
Wrap generated enum and struct members and their supporting code with #if/#endif, using the .ifcond members added in the previous patches. We do enum and struct in a single patch because union tag enum and the associated variants tie them together, and dealing with that to split the patch doesn't seem worthwhile. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20181213123724.4866-18-marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
committed by
Markus Armbruster
parent
3e270dcacc
commit
8ee06f61e1
@ -43,6 +43,7 @@ struct %(c_name)s {
|
||||
def gen_struct_members(members):
|
||||
ret = ''
|
||||
for memb in members:
|
||||
ret += gen_if(memb.ifcond)
|
||||
if memb.optional:
|
||||
ret += mcgen('''
|
||||
bool has_%(c_name)s;
|
||||
@ -52,6 +53,7 @@ def gen_struct_members(members):
|
||||
%(c_type)s %(c_name)s;
|
||||
''',
|
||||
c_type=memb.type.c_type(), c_name=c_name(memb.name))
|
||||
ret += gen_endif(memb.ifcond)
|
||||
return ret
|
||||
|
||||
|
||||
@ -131,11 +133,13 @@ def gen_variants(variants):
|
||||
for var in variants.variants:
|
||||
if var.type.name == 'q_empty':
|
||||
continue
|
||||
ret += gen_if(var.ifcond)
|
||||
ret += mcgen('''
|
||||
%(c_type)s %(c_name)s;
|
||||
''',
|
||||
c_type=var.type.c_unboxed_type(),
|
||||
c_name=c_name(var.name))
|
||||
ret += gen_endif(var.ifcond)
|
||||
|
||||
ret += mcgen('''
|
||||
} u;
|
||||
|
Reference in New Issue
Block a user