qapi: fixup command generation for functions that return list types

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
Anthony Liguori 2011-09-14 14:30:00 -05:00 committed by Luiz Capitulino
parent e3193601c8
commit 15e43e64b6

View File

@ -17,12 +17,18 @@ import os
import getopt import getopt
import errno import errno
def type_visitor(name):
if type(name) == list:
return 'visit_type_%sList' % name[0]
else:
return 'visit_type_%s' % name
def generate_decl_enum(name, members, genlist=True): def generate_decl_enum(name, members, genlist=True):
return mcgen(''' return mcgen('''
void visit_type_%(name)s(Visitor *m, %(name)s * obj, const char *name, Error **errp); void %(visitor)s(Visitor *m, %(name)s * obj, const char *name, Error **errp);
''', ''',
name=name) visitor=type_visitor(name))
def generate_command_decl(name, args, ret_type): def generate_command_decl(name, args, ret_type):
arglist="" arglist=""
@ -146,9 +152,10 @@ if (has_%(c_name)s) {
c_name=c_var(argname), name=argname) c_name=c_var(argname), name=argname)
push_indent() push_indent()
ret += mcgen(''' ret += mcgen('''
visit_type_%(argtype)s(v, &%(c_name)s, "%(name)s", errp); %(visitor)s(v, &%(c_name)s, "%(name)s", errp);
''', ''',
c_name=c_var(argname), name=argname, argtype=argtype) c_name=c_var(argname), name=argname, argtype=argtype,
visitor=type_visitor(argtype))
if optional: if optional:
pop_indent() pop_indent()
ret += mcgen(''' ret += mcgen('''
@ -179,18 +186,18 @@ static void qmp_marshal_output_%(c_name)s(%(c_ret_type)s ret_in, QObject **ret_o
Visitor *v; Visitor *v;
v = qmp_output_get_visitor(mo); v = qmp_output_get_visitor(mo);
visit_type_%(ret_type)s(v, &ret_in, "unused", errp); %(visitor)s(v, &ret_in, "unused", errp);
if (!error_is_set(errp)) { if (!error_is_set(errp)) {
*ret_out = qmp_output_get_qobject(mo); *ret_out = qmp_output_get_qobject(mo);
} }
qmp_output_visitor_cleanup(mo); qmp_output_visitor_cleanup(mo);
v = qapi_dealloc_get_visitor(md); v = qapi_dealloc_get_visitor(md);
visit_type_%(ret_type)s(v, &ret_in, "unused", errp); %(visitor)s(v, &ret_in, "unused", errp);
qapi_dealloc_visitor_cleanup(md); qapi_dealloc_visitor_cleanup(md);
} }
''', ''',
c_ret_type=c_type(ret_type), c_name=c_var(name), c_ret_type=c_type(ret_type), c_name=c_var(name),
ret_type=ret_type) visitor=type_visitor(ret_type))
return ret return ret