mirror of https://github.com/proxmox/mirror_qemu
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>master
parent
9b4416bfc1
commit
675b214bc6
|
@ -30,7 +30,7 @@ def gen_call(name, arg_type, boxed, ret_type):
|
||||||
|
|
||||||
argstr = ''
|
argstr = ''
|
||||||
if boxed:
|
if boxed:
|
||||||
assert arg_type and not arg_type.is_empty()
|
assert arg_type
|
||||||
argstr = '&arg, '
|
argstr = '&arg, '
|
||||||
elif arg_type:
|
elif arg_type:
|
||||||
assert not arg_type.variants
|
assert not arg_type.variants
|
||||||
|
@ -96,7 +96,7 @@ def gen_marshal_decl(name):
|
||||||
|
|
||||||
|
|
||||||
def gen_marshal(name, arg_type, boxed, ret_type):
|
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('''
|
ret = mcgen('''
|
||||||
|
|
||||||
|
|
|
@ -1687,12 +1687,7 @@ class QAPISchemaCommand(QAPISchemaEntity):
|
||||||
self.arg_type = schema.lookup_type(self._arg_type_name)
|
self.arg_type = schema.lookup_type(self._arg_type_name)
|
||||||
assert isinstance(self.arg_type, QAPISchemaObjectType)
|
assert isinstance(self.arg_type, QAPISchemaObjectType)
|
||||||
self.arg_type.check(schema)
|
self.arg_type.check(schema)
|
||||||
if self.boxed:
|
assert not self.arg_type.variants or 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
|
|
||||||
elif self.boxed:
|
elif self.boxed:
|
||||||
raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
|
raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
|
||||||
if self._ret_type_name:
|
if self._ret_type_name:
|
||||||
|
@ -1721,12 +1716,7 @@ class QAPISchemaEvent(QAPISchemaEntity):
|
||||||
self.arg_type = schema.lookup_type(self._arg_type_name)
|
self.arg_type = schema.lookup_type(self._arg_type_name)
|
||||||
assert isinstance(self.arg_type, QAPISchemaObjectType)
|
assert isinstance(self.arg_type, QAPISchemaObjectType)
|
||||||
self.arg_type.check(schema)
|
self.arg_type.check(schema)
|
||||||
if self.boxed:
|
assert not self.arg_type.variants or 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
|
|
||||||
elif self.boxed:
|
elif self.boxed:
|
||||||
raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
|
raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
|
||||||
|
|
||||||
|
|
|
@ -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,
|
# practice, we can rename our local variables with a leading _ prefix,
|
||||||
# or split the code into a wrapper function that creates a boxed
|
# or split the code into a wrapper function that creates a boxed
|
||||||
# 'param' object then calls another to do the real work.
|
# 'param' object then calls another to do the real work.
|
||||||
|
have_args = boxed or (arg_type and not arg_type.is_empty())
|
||||||
|
|
||||||
ret = mcgen('''
|
ret = mcgen('''
|
||||||
|
|
||||||
%(proto)s
|
%(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))
|
proto=build_event_send_proto(name, arg_type, boxed))
|
||||||
|
|
||||||
if arg_type and not arg_type.is_empty():
|
if have_args:
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
QObject *obj;
|
QObject *obj;
|
||||||
Visitor *v;
|
Visitor *v;
|
||||||
''')
|
''')
|
||||||
if not boxed:
|
if not boxed:
|
||||||
ret += gen_param_var(arg_type)
|
ret += gen_param_var(arg_type)
|
||||||
else:
|
|
||||||
assert not boxed
|
|
||||||
|
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ def gen_event_send(name, arg_type, boxed, event_enum_name, event_emit):
|
||||||
''',
|
''',
|
||||||
name=name)
|
name=name)
|
||||||
|
|
||||||
if arg_type and not arg_type.is_empty():
|
if have_args:
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
v = qobject_output_visitor_new(&obj);
|
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,
|
event_emit=event_emit,
|
||||||
c_enum=c_enum_const(event_enum_name, name))
|
c_enum=c_enum_const(event_enum_name, name))
|
||||||
|
|
||||||
if arg_type and not arg_type.is_empty():
|
if have_args:
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
visit_free(v);
|
visit_free(v);
|
||||||
''')
|
''')
|
||||||
|
|
|
@ -311,7 +311,6 @@ qapi-schema += args-array-empty.json
|
||||||
qapi-schema += args-array-unknown.json
|
qapi-schema += args-array-unknown.json
|
||||||
qapi-schema += args-bad-boxed.json
|
qapi-schema += args-bad-boxed.json
|
||||||
qapi-schema += args-boxed-anon.json
|
qapi-schema += args-boxed-anon.json
|
||||||
qapi-schema += args-boxed-empty.json
|
|
||||||
qapi-schema += args-boxed-string.json
|
qapi-schema += args-boxed-string.json
|
||||||
qapi-schema += args-int.json
|
qapi-schema += args-int.json
|
||||||
qapi-schema += args-invalid.json
|
qapi-schema += args-invalid.json
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
tests/qapi-schema/args-boxed-empty.json:3: Cannot use 'boxed' with empty type
|
|
|
@ -1 +0,0 @@
|
||||||
1
|
|
|
@ -1,3 +0,0 @@
|
||||||
# 'boxed' requires a non-empty type
|
|
||||||
{ 'struct': 'Empty', 'data': {} }
|
|
||||||
{ 'command': 'foo', 'boxed': true, 'data': 'Empty' }
|
|
|
@ -149,6 +149,7 @@
|
||||||
{ 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' }
|
{ 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' }
|
||||||
{ 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' }
|
{ 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' }
|
||||||
{ 'command': 'boxed-union', 'data': 'UserDefListUnion', 'boxed': true }
|
{ 'command': 'boxed-union', 'data': 'UserDefListUnion', 'boxed': true }
|
||||||
|
{ 'command': 'boxed-empty', 'boxed': true, 'data': 'Empty1' }
|
||||||
|
|
||||||
# Smoke test on out-of-band and allow-preconfig-test
|
# Smoke test on out-of-band and allow-preconfig-test
|
||||||
{ 'command': 'test-flags-command', 'allow-oob': true, 'allow-preconfig': true }
|
{ 'command': 'test-flags-command', 'allow-oob': true, 'allow-preconfig': true }
|
||||||
|
@ -181,6 +182,7 @@
|
||||||
'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } }
|
'data': { 'a' : 'EventStructOne', 'b' : 'str', '*c': 'str', '*enum3': 'EnumOne' } }
|
||||||
{ 'event': 'EVENT_E', 'boxed': true, 'data': 'UserDefZero' }
|
{ 'event': 'EVENT_E', 'boxed': true, 'data': 'UserDefZero' }
|
||||||
{ 'event': 'EVENT_F', 'boxed': true, 'data': 'UserDefFlatUnion' }
|
{ 'event': 'EVENT_F', 'boxed': true, 'data': 'UserDefFlatUnion' }
|
||||||
|
{ 'event': 'EVENT_G', 'boxed': true, 'data': 'Empty1' }
|
||||||
|
|
||||||
# test that we correctly compile downstream extensions, as well as munge
|
# test that we correctly compile downstream extensions, as well as munge
|
||||||
# ticklish names
|
# ticklish names
|
||||||
|
|
|
@ -221,6 +221,8 @@ command boxed-struct UserDefZero -> None
|
||||||
gen=True success_response=True boxed=True oob=False preconfig=False
|
gen=True success_response=True boxed=True oob=False preconfig=False
|
||||||
command boxed-union UserDefListUnion -> None
|
command boxed-union UserDefListUnion -> None
|
||||||
gen=True success_response=True boxed=True oob=False preconfig=False
|
gen=True success_response=True boxed=True oob=False preconfig=False
|
||||||
|
command boxed-empty Empty1 -> None
|
||||||
|
gen=True success_response=True boxed=True oob=False preconfig=False
|
||||||
command test-flags-command None -> None
|
command test-flags-command None -> None
|
||||||
gen=True success_response=True boxed=False oob=True preconfig=True
|
gen=True success_response=True boxed=False oob=True preconfig=True
|
||||||
object UserDefOptions
|
object UserDefOptions
|
||||||
|
@ -254,6 +256,8 @@ event EVENT_E UserDefZero
|
||||||
boxed=True
|
boxed=True
|
||||||
event EVENT_F UserDefFlatUnion
|
event EVENT_F UserDefFlatUnion
|
||||||
boxed=True
|
boxed=True
|
||||||
|
event EVENT_G Empty1
|
||||||
|
boxed=True
|
||||||
enum __org.qemu_x-Enum
|
enum __org.qemu_x-Enum
|
||||||
member __org.qemu_x-value
|
member __org.qemu_x-value
|
||||||
object __org.qemu_x-Base
|
object __org.qemu_x-Base
|
||||||
|
|
|
@ -97,6 +97,10 @@ void qmp_boxed_union(UserDefListUnion *arg, Error **errp)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qmp_boxed_empty(Empty1 *arg, Error **errp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
__org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a,
|
__org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a,
|
||||||
__org_qemu_x_StructList *b,
|
__org_qemu_x_StructList *b,
|
||||||
__org_qemu_x_Union2 *c,
|
__org_qemu_x_Union2 *c,
|
||||||
|
|
Loading…
Reference in New Issue