Skip to content
Snippets Groups Projects
Commit f87ab7f9 authored by Eric Blake's avatar Eric Blake Committed by Markus Armbruster
Browse files

qapi-types: Refactor base fields output


Move code from gen_union() into gen_struct_fields() in order for
a later patch to share code when enumerating inherited fields
for struct types.

No change to generated code.

Signed-off-by: default avatarEric Blake <eblake@redhat.com>
Message-Id: <1445898903-12082-9-git-send-email-eblake@redhat.com>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent d02cf377
No related branches found
No related tags found
No related merge requests found
......@@ -51,10 +51,21 @@ def gen_struct_field(name, typ, optional):
return ret
def gen_struct_fields(members):
def gen_struct_fields(local_members, base=None):
ret = ''
for memb in members:
if base:
ret += mcgen('''
/* Members inherited from %(c_name)s: */
''',
c_name=base.c_name())
for memb in base.members:
ret += gen_struct_field(memb.name, memb.type, memb.optional)
ret += mcgen('''
/* Own members: */
''')
for memb in local_members:
ret += gen_struct_field(memb.name, memb.type, memb.optional)
return ret
......@@ -126,14 +137,7 @@ def gen_union(name, base, variants):
''',
c_name=c_name(name))
if base:
ret += mcgen('''
/* Members inherited from %(c_name)s: */
''',
c_name=c_name(base.name))
ret += gen_struct_fields(base.members)
ret += mcgen('''
/* Own members: */
''')
ret += gen_struct_fields([], base)
else:
ret += mcgen('''
%(c_type)s kind;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment