qapi-types.py: Split off generate_struct_fields()

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Kevin Wolf 2013-07-02 12:18:18 +02:00
parent 09da4a7292
commit 015370301f

View File

@ -57,12 +57,8 @@ typedef struct %(name)sList
''', ''',
name=name) name=name)
def generate_struct(structname, fieldname, members): def generate_struct_fields(members):
ret = mcgen(''' ret = ''
struct %(name)s
{
''',
name=structname)
for argname, argentry, optional, structured in parse_args(members): for argname, argentry, optional, structured in parse_args(members):
if optional: if optional:
@ -80,6 +76,17 @@ struct %(name)s
''', ''',
c_type=c_type(argentry), c_name=c_var(argname)) 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): if len(fieldname):
fieldname = " " + fieldname fieldname = " " + fieldname
ret += mcgen(''' ret += mcgen('''