aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi-commands.py33
-rw-r--r--scripts/qapi-event.py12
-rw-r--r--scripts/qapi-types.py6
-rw-r--r--scripts/qapi-visit.py8
4 files changed, 24 insertions, 35 deletions
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 8c6acb3..34b6a3a 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -61,24 +61,18 @@ def gen_marshal_output(ret_type):
static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out, Error **errp)
{
Error *err = NULL;
- QmpOutputVisitor *qov = qmp_output_visitor_new();
- QapiDeallocVisitor *qdv;
Visitor *v;
- v = qmp_output_get_visitor(qov);
+ v = qmp_output_visitor_new(ret_out);
visit_type_%(c_name)s(v, "unused", &ret_in, &err);
- if (err) {
- goto out;
+ if (!err) {
+ visit_complete(v, ret_out);
}
- *ret_out = qmp_output_get_qobject(qov);
-
-out:
error_propagate(errp, err);
- qmp_output_visitor_cleanup(qov);
- qdv = qapi_dealloc_visitor_new();
- v = qapi_dealloc_get_visitor(qdv);
+ visit_free(v);
+ v = qapi_dealloc_visitor_new();
visit_type_%(c_name)s(v, "unused", &ret_in, NULL);
- qapi_dealloc_visitor_cleanup(qdv);
+ visit_free(v);
}
''',
c_type=ret_type.c_type(), c_name=ret_type.c_name())
@@ -115,12 +109,10 @@ def gen_marshal(name, arg_type, ret_type):
if arg_type and arg_type.members:
ret += mcgen('''
- QmpInputVisitor *qiv = qmp_input_visitor_new(QOBJECT(args), true);
- QapiDeallocVisitor *qdv;
Visitor *v;
%(c_name)s arg = {0};
- v = qmp_input_get_visitor(qiv);
+ v = qmp_input_visitor_new(QOBJECT(args), true);
visit_start_struct(v, NULL, NULL, 0, &err);
if (err) {
goto out;
@@ -129,7 +121,7 @@ def gen_marshal(name, arg_type, ret_type):
if (!err) {
visit_check_struct(v, &err);
}
- visit_end_struct(v);
+ visit_end_struct(v, NULL);
if (err) {
goto out;
}
@@ -155,13 +147,12 @@ out:
''')
if arg_type and arg_type.members:
ret += mcgen('''
- qmp_input_visitor_cleanup(qiv);
- qdv = qapi_dealloc_visitor_new();
- v = qapi_dealloc_get_visitor(qdv);
+ visit_free(v);
+ v = qapi_dealloc_visitor_new();
visit_start_struct(v, NULL, NULL, 0, NULL);
visit_type_%(c_name)s_members(v, &arg, NULL);
- visit_end_struct(v);
- qapi_dealloc_visitor_cleanup(qdv);
+ visit_end_struct(v, NULL);
+ visit_free(v);
''',
c_name=arg_type.c_name())
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index 21fb167..9c88627 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -71,7 +71,7 @@ def gen_event_send(name, arg_type):
if arg_type and arg_type.members:
ret += mcgen('''
- QmpOutputVisitor *qov;
+ QObject *obj;
Visitor *v;
''')
ret += gen_param_var(arg_type)
@@ -90,8 +90,7 @@ def gen_event_send(name, arg_type):
if arg_type and arg_type.members:
ret += mcgen('''
- qov = qmp_output_visitor_new();
- v = qmp_output_get_visitor(qov);
+ v = qmp_output_visitor_new(&obj);
visit_start_struct(v, "%(name)s", NULL, 0, &err);
if (err) {
@@ -101,12 +100,13 @@ def gen_event_send(name, arg_type):
if (!err) {
visit_check_struct(v, &err);
}
- visit_end_struct(v);
+ visit_end_struct(v, NULL);
if (err) {
goto out;
}
- qdict_put_obj(qmp, "data", qmp_output_get_qobject(qov));
+ visit_complete(v, &obj);
+ qdict_put_obj(qmp, "data", obj);
''',
name=name, c_name=arg_type.c_name())
@@ -119,7 +119,7 @@ def gen_event_send(name, arg_type):
if arg_type and arg_type.members:
ret += mcgen('''
out:
- qmp_output_visitor_cleanup(qov);
+ visit_free(v);
''')
ret += mcgen('''
error_propagate(errp, err);
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 437cf6c..5ace2cf 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -150,17 +150,15 @@ def gen_type_cleanup(name):
void qapi_free_%(c_name)s(%(c_name)s *obj)
{
- QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
- qdv = qapi_dealloc_visitor_new();
- v = qapi_dealloc_get_visitor(qdv);
+ v = qapi_dealloc_visitor_new();
visit_type_%(c_name)s(v, NULL, &obj, NULL);
- qapi_dealloc_visitor_cleanup(qdv);
+ visit_free(v);
}
''',
c_name=c_name(name))
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index ffb635c..0b9e298 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -129,7 +129,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
}
}
- visit_end_list(v);
+ visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_%(c_name)s(*obj);
*obj = NULL;
@@ -194,7 +194,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
if (!err) {
visit_check_struct(v, &err);
}
- visit_end_struct(v);
+ visit_end_struct(v, NULL);
''',
c_type=var.type.c_name(),
c_name=c_name(var.name))
@@ -216,7 +216,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
"%(name)s");
}
out_obj:
- visit_end_alternate(v);
+ visit_end_alternate(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_%(c_name)s(*obj);
*obj = NULL;
@@ -250,7 +250,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
}
visit_check_struct(v, &err);
out_obj:
- visit_end_struct(v);
+ visit_end_struct(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_%(c_name)s(*obj);
*obj = NULL;