mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
qapi: Plumb in 'boxed' to qapi generator lower levels
The next patch will add support for passing a qapi union type as the 'data' of a command. But to do that, the user function for implementing the command, as called by the generated marshal command, must take the corresponding C struct as a single boxed pointer, rather than a breakdown into one parameter per member. Even without a union, being able to use a C struct rather than a list of parameters can make it much easier to handle coding with QAPI. This patch adds the internal plumbing of a 'boxed' flag associated with each command and event. In several cases, this means adding indentation, with one new dead branch and the remaining branch being the original code more deeply nested; this was done so that the new implementation in the next patch is easier to review without also being mixed with indentation changes. For this patch, no behavior or generated output changes, other than the testsuite outputting the value of the new flag (always False for now). Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1468468228-27827-9-git-send-email-eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Identifier box renamed to boxed in two places] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
4d0b268fdb
commit
48825ca419
9 changed files with 70 additions and 49 deletions
|
@ -14,18 +14,18 @@
|
|||
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()
|
||||
|
@ -57,7 +57,7 @@ def gen_param_var(typ):
|
|||
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
|
||||
|
@ -72,7 +72,7 @@ def gen_event_send(name, arg_type):
|
|||
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 not arg_type.is_empty():
|
||||
ret += mcgen('''
|
||||
|
@ -160,9 +160,9 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
|
|||
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)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue