qapi-types/visit.py: Pass whole expr dict for structs

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Kevin Wolf 2013-09-18 17:22:02 +02:00
parent 52c8d629ca
commit 14d36307ff
2 changed files with 14 additions and 5 deletions

View File

@ -71,7 +71,7 @@ def generate_struct_fields(members):
c_name=c_var(argname)) c_name=c_var(argname))
if structured: if structured:
push_indent() push_indent()
ret += generate_struct("", argname, argentry) ret += generate_struct({ "field": argname, "data": argentry})
pop_indent() pop_indent()
else: else:
ret += mcgen(''' ret += mcgen('''
@ -81,7 +81,12 @@ def generate_struct_fields(members):
return ret return ret
def generate_struct(structname, fieldname, members): def generate_struct(expr):
structname = expr.get('type', "")
fieldname = expr.get('field', "")
members = expr['data']
ret = mcgen(''' ret = mcgen('''
struct %(name)s struct %(name)s
{ {
@ -417,7 +422,7 @@ if do_builtins:
for expr in exprs: for expr in exprs:
ret = "\n" ret = "\n"
if expr.has_key('type'): if expr.has_key('type'):
ret += generate_struct(expr['type'], "", expr['data']) + "\n" ret += generate_struct(expr) + "\n"
ret += generate_type_cleanup_decl(expr['type'] + "List") ret += generate_type_cleanup_decl(expr['type'] + "List")
fdef.write(generate_type_cleanup(expr['type'] + "List") + "\n") fdef.write(generate_type_cleanup(expr['type'] + "List") + "\n")
ret += generate_type_cleanup_decl(expr['type']) ret += generate_type_cleanup_decl(expr['type'])

View File

@ -120,7 +120,11 @@ if (!err) {
''') ''')
return ret return ret
def generate_visit_struct(name, members): def generate_visit_struct(expr):
name = expr['type']
members = expr['data']
ret = generate_visit_struct_fields(name, "", "", members) ret = generate_visit_struct_fields(name, "", "", members)
ret += mcgen(''' ret += mcgen('''
@ -472,7 +476,7 @@ if do_builtins:
for expr in exprs: for expr in exprs:
if expr.has_key('type'): if expr.has_key('type'):
ret = generate_visit_struct(expr['type'], expr['data']) ret = generate_visit_struct(expr)
ret += generate_visit_list(expr['type'], expr['data']) ret += generate_visit_list(expr['type'], expr['data'])
fdef.write(ret) fdef.write(ret)