from qapi import *
-def gen_event_send_proto(name, arg_type):
+def gen_event_send_proto(name, arg_type, boxed):
return 'void qapi_event_send_%(c_name)s(%(param)s)' % {
'c_name': c_name(name.lower()),
- 'param': gen_params(arg_type, 'Error **errp')}
+ 'param': gen_params(arg_type, boxed, 'Error **errp')}
-def gen_event_send_decl(name, arg_type):
+def gen_event_send_decl(name, arg_type, boxed):
return mcgen('''
%(proto)s;
''',
- proto=gen_event_send_proto(name, arg_type))
+ proto=gen_event_send_proto(name, arg_type, boxed))
# Declare and initialize an object 'qapi' using parameters from gen_params()
};
''')
+ if not typ.is_implicit():
+ ret += mcgen('''
+ %(c_name)s *arg = ¶m;
+''',
+ c_name=typ.c_name())
return ret
-def gen_event_send(name, arg_type):
+def gen_event_send(name, arg_type, boxed):
# FIXME: Our declaration of local variables (and of 'errp' in the
# parameter list) can collide with exploded members of the event's
# data type passed in as parameters. If this collision ever hits in
Error *err = NULL;
QMPEventFuncEmit emit;
''',
- proto=gen_event_send_proto(name, arg_type))
+ proto=gen_event_send_proto(name, arg_type, boxed))
- if arg_type and arg_type.members:
+ if arg_type and not arg_type.is_empty():
ret += mcgen('''
- QmpOutputVisitor *qov;
+ QObject *obj;
Visitor *v;
''')
- ret += gen_param_var(arg_type)
+ if not boxed:
+ ret += gen_param_var(arg_type)
+ else:
+ assert not boxed
ret += mcgen('''
''',
name=name)
- if arg_type and arg_type.members:
+ if arg_type and not arg_type.is_empty():
ret += mcgen('''
- qov = qmp_output_visitor_new();
- v = qmp_output_get_visitor(qov);
+ v = qobject_output_visitor_new(&obj);
+''')
+ if not arg_type.is_implicit():
+ ret += mcgen('''
+ visit_type_%(c_name)s(v, "%(name)s", &arg, &err);
+''',
+ name=name, c_name=arg_type.c_name())
+ else:
+ ret += mcgen('''
visit_start_struct(v, "%(name)s", NULL, 0, &err);
if (err) {
if (!err) {
visit_check_struct(v, &err);
}
- visit_end_struct(v);
+ visit_end_struct(v, NULL);
+''',
+ name=name, c_name=arg_type.c_name())
+ ret += mcgen('''
if (err) {
goto out;
}
- qdict_put_obj(qmp, "data", qmp_output_get_qobject(qov));
-''',
- name=name, c_name=arg_type.c_name())
+ visit_complete(v, &obj);
+ qdict_put_obj(qmp, "data", obj);
+''')
ret += mcgen('''
emit(%(c_enum)s, qmp, &err);
''',
c_enum=c_enum_const(event_enum_name, name))
- if arg_type and arg_type.members:
+ if arg_type and not arg_type.is_empty():
ret += mcgen('''
out:
- qmp_output_visitor_cleanup(qov);
+ visit_free(v);
''')
ret += mcgen('''
error_propagate(errp, err);
self.defn += gen_enum_lookup(event_enum_name, self._event_names)
self._event_names = None
- def visit_event(self, name, info, arg_type):
- self.decl += gen_event_send_decl(name, arg_type)
- self.defn += gen_event_send(name, arg_type)
+ def visit_event(self, name, info, arg_type, boxed):
+ self.decl += gen_event_send_decl(name, arg_type, boxed)
+ self.defn += gen_event_send(name, arg_type, boxed)
self._event_names.append(name)
#include "qemu-common.h"
#include "%(prefix)sqapi-event.h"
#include "%(prefix)sqapi-visit.h"
-#include "qapi/qmp-output-visitor.h"
+#include "qapi/qobject-output-visitor.h"
#include "qapi/qmp-event.h"
''',
''',
prefix=prefix))
-event_enum_name = c_name(prefix + "QAPIEvent", protect=False)
+event_enum_name = c_name(prefix + 'QAPIEvent', protect=False)
schema = QAPISchema(input_file)
gen = QAPISchemaGenEventVisitor()