summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-09-14 14:30:00 -0500
committerLuiz Capitulino <lcapitulino@redhat.com>2011-10-04 11:00:46 -0300
commit15e43e64b6bac61811e829634ee048e8de4c976d (patch)
tree3e811963349d97af715218dbe2624bd2798a6046 /scripts
parente3193601c84558c303b1773379da76fce80c0a56 (diff)
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>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi-commands.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 27768049a8..c947ba4208 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -17,12 +17,18 @@ import os
import getopt
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):
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):
arglist=""
@@ -146,9 +152,10 @@ if (has_%(c_name)s) {
c_name=c_var(argname), name=argname)
push_indent()
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:
pop_indent()
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;
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)) {
*ret_out = qmp_output_get_qobject(mo);
}
qmp_output_visitor_cleanup(mo);
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);
}
''',
- c_ret_type=c_type(ret_type), c_name=c_var(name),
- ret_type=ret_type)
+ c_ret_type=c_type(ret_type), c_name=c_var(name),
+ visitor=type_visitor(ret_type))
return ret