diff options
author | Markus Armbruster <armbru@redhat.com> | 2019-09-13 22:13:41 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2019-09-24 14:07:22 +0200 |
commit | 675b214bc6ba2c1d8ac499e339a8cb99c7f23c7c (patch) | |
tree | e8dd67e031288e45927b128d21d687143b7aac6d /scripts | |
parent | 9b4416bfc1ea5fb3398e8f78a90caa88dd301c37 (diff) |
qapi: Permit 'boxed' with empty type
We reject empty types with 'boxed': true. We don't really need that
to work, but making it work is actually simpler than rejecting it, so
do that.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190913201349.24332-9-armbru@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qapi/commands.py | 4 | ||||
-rw-r--r-- | scripts/qapi/common.py | 14 | ||||
-rw-r--r-- | scripts/qapi/events.py | 10 |
3 files changed, 9 insertions, 19 deletions
diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index b929e07be4..7e3dd1068a 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -30,7 +30,7 @@ def gen_call(name, arg_type, boxed, ret_type): argstr = '' if boxed: - assert arg_type and not arg_type.is_empty() + assert arg_type argstr = '&arg, ' elif arg_type: assert not arg_type.variants @@ -96,7 +96,7 @@ def gen_marshal_decl(name): def gen_marshal(name, arg_type, boxed, ret_type): - have_args = arg_type and not arg_type.is_empty() + have_args = boxed or (arg_type and not arg_type.is_empty()) ret = mcgen(''' diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 0fb1d1956a..c5c71287c3 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -1687,12 +1687,7 @@ class QAPISchemaCommand(QAPISchemaEntity): self.arg_type = schema.lookup_type(self._arg_type_name) assert isinstance(self.arg_type, QAPISchemaObjectType) self.arg_type.check(schema) - if self.boxed: - if self.arg_type.is_empty(): - raise QAPISemError(self.info, - "Cannot use 'boxed' with empty type") - else: - assert not self.arg_type.variants + assert not self.arg_type.variants or self.boxed elif self.boxed: raise QAPISemError(self.info, "Use of 'boxed' requires 'data'") if self._ret_type_name: @@ -1721,12 +1716,7 @@ class QAPISchemaEvent(QAPISchemaEntity): self.arg_type = schema.lookup_type(self._arg_type_name) assert isinstance(self.arg_type, QAPISchemaObjectType) self.arg_type.check(schema) - if self.boxed: - if self.arg_type.is_empty(): - raise QAPISemError(self.info, - "Cannot use 'boxed' with empty type") - else: - assert not self.arg_type.variants + assert not self.arg_type.variants or self.boxed elif self.boxed: raise QAPISemError(self.info, "Use of 'boxed' requires 'data'") diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index b732581046..e0abfef7b0 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -65,6 +65,8 @@ def gen_event_send(name, arg_type, boxed, event_enum_name, event_emit): # practice, we can rename our local variables with a leading _ prefix, # or split the code into a wrapper function that creates a boxed # 'param' object then calls another to do the real work. + have_args = boxed or (arg_type and not arg_type.is_empty()) + ret = mcgen(''' %(proto)s @@ -73,15 +75,13 @@ def gen_event_send(name, arg_type, boxed, event_enum_name, event_emit): ''', proto=build_event_send_proto(name, arg_type, boxed)) - if arg_type and not arg_type.is_empty(): + if have_args: ret += mcgen(''' QObject *obj; Visitor *v; ''') if not boxed: ret += gen_param_var(arg_type) - else: - assert not boxed ret += mcgen(''' @@ -90,7 +90,7 @@ def gen_event_send(name, arg_type, boxed, event_enum_name, event_emit): ''', name=name) - if arg_type and not arg_type.is_empty(): + if have_args: ret += mcgen(''' v = qobject_output_visitor_new(&obj); ''') @@ -121,7 +121,7 @@ def gen_event_send(name, arg_type, boxed, event_enum_name, event_emit): event_emit=event_emit, c_enum=c_enum_const(event_enum_name, name)) - if arg_type and not arg_type.is_empty(): + if have_args: ret += mcgen(''' visit_free(v); ''') |