aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-10-26 16:34:47 -0600
committerMarkus Armbruster <armbru@redhat.com>2015-11-02 08:30:26 +0100
commitf87ab7f9bd956250c48b5c6e9b607b537fd21543 (patch)
tree287a8a60f6637c934103bedd94113f7089247b70 /scripts
parentd02cf37766ba3cf918d7085aa7848c9dc05fd11a (diff)
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: Eric Blake <eblake@redhat.com> Message-Id: <1445898903-12082-9-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi-types.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 4fe618ef3c..40e9f79b63 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -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 @@ struct %(c_name)s {
''',
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;