aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2013-07-02 12:18:18 +0200
committerKevin Wolf <kwolf@redhat.com>2013-08-30 15:28:52 +0200
commit015370301fd90ea5d17522eba00ae2797569ce8b (patch)
tree85bfcab53b9e3eecee67c9fcca17e4a2cc9e8628 /scripts
parent09da4a72926e2d0af0e5f0cb967ab0dd345311f4 (diff)
qapi-types.py: Split off generate_struct_fields()
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi-types.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 5ee46ea1b3..86de9800ea 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -57,12 +57,8 @@ typedef struct %(name)sList
''',
name=name)
-def generate_struct(structname, fieldname, members):
- ret = mcgen('''
-struct %(name)s
-{
-''',
- name=structname)
+def generate_struct_fields(members):
+ ret = ''
for argname, argentry, optional, structured in parse_args(members):
if optional:
@@ -80,6 +76,17 @@ struct %(name)s
''',
c_type=c_type(argentry), c_name=c_var(argname))
+ return ret
+
+def generate_struct(structname, fieldname, members):
+ ret = mcgen('''
+struct %(name)s
+{
+''',
+ name=structname)
+
+ ret += generate_struct_fields(members)
+
if len(fieldname):
fieldname = " " + fieldname
ret += mcgen('''