mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
qapi: add 'if' to enum members
QAPISchemaMember gains .ifcond for enum members: inherited classes, such as QAPISchemaObjectTypeMember, will thus have an ifcond member after this (those different types will also use the .ifcond to store the condition and generate conditional code in the following patches). The generated code remains unconditional for now. Later patches generate the conditionals. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20181213123724.4866-10-marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
ea738b2168
commit
6cc32b0e14
11 changed files with 27 additions and 6 deletions
|
@ -1,2 +1,2 @@
|
|||
tests/qapi-schema/enum-dict-member-unknown.json:2: Unknown key 'bad-key' in dictionary member of enum 'MyEnum'
|
||||
Valid keys are 'name'.
|
||||
Valid keys are 'if', 'name'.
|
||||
|
|
1
tests/qapi-schema/enum-if-invalid.err
Normal file
1
tests/qapi-schema/enum-if-invalid.err
Normal file
|
@ -0,0 +1 @@
|
|||
tests/qapi-schema/enum-if-invalid.json:2: 'if' condition must be a string or a list of strings
|
1
tests/qapi-schema/enum-if-invalid.exit
Normal file
1
tests/qapi-schema/enum-if-invalid.exit
Normal file
|
@ -0,0 +1 @@
|
|||
1
|
3
tests/qapi-schema/enum-if-invalid.json
Normal file
3
tests/qapi-schema/enum-if-invalid.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
# check invalid 'if' type
|
||||
{ 'enum': 'TestIfEnum', 'data':
|
||||
[ 'foo', { 'name' : 'bar', 'if': { 'val': 'foo' } } ] }
|
0
tests/qapi-schema/enum-if-invalid.out
Normal file
0
tests/qapi-schema/enum-if-invalid.out
Normal file
|
@ -204,7 +204,8 @@
|
|||
{ 'struct': 'TestIfStruct', 'data': { 'foo': 'int' },
|
||||
'if': 'defined(TEST_IF_STRUCT)' }
|
||||
|
||||
{ 'enum': 'TestIfEnum', 'data': [ 'foo', 'bar' ],
|
||||
{ 'enum': 'TestIfEnum', 'data':
|
||||
[ 'foo', { 'name' : 'bar', 'if': 'defined(TEST_IF_ENUM_BAR)' } ],
|
||||
'if': 'defined(TEST_IF_ENUM)' }
|
||||
|
||||
{ 'union': 'TestIfUnion', 'data': { 'foo': 'TestStruct' },
|
||||
|
@ -219,7 +220,7 @@
|
|||
{ 'command': 'TestIfAlternateCmd', 'data': { 'alt_cmd_arg': 'TestIfAlternate' },
|
||||
'if': 'defined(TEST_IF_ALT)' }
|
||||
|
||||
{ 'command': 'TestIfCmd', 'data': { 'foo': 'TestIfStruct' },
|
||||
{ 'command': 'TestIfCmd', 'data': { 'foo': 'TestIfStruct', 'bar': 'TestIfEnum' },
|
||||
'returns': 'UserDefThree',
|
||||
'if': ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)'] }
|
||||
|
||||
|
|
|
@ -272,6 +272,7 @@ object TestIfStruct
|
|||
enum TestIfEnum
|
||||
member foo
|
||||
member bar
|
||||
if ['defined(TEST_IF_ENUM_BAR)']
|
||||
if ['defined(TEST_IF_ENUM)']
|
||||
object q_obj_TestStruct-wrapper
|
||||
member data: TestStruct optional=False
|
||||
|
@ -302,6 +303,7 @@ command TestIfAlternateCmd q_obj_TestIfAlternateCmd-arg -> None
|
|||
if ['defined(TEST_IF_ALT)']
|
||||
object q_obj_TestIfCmd-arg
|
||||
member foo: TestIfStruct optional=False
|
||||
member bar: TestIfEnum optional=False
|
||||
if ['defined(TEST_IF_CMD)', 'defined(TEST_IF_STRUCT)']
|
||||
command TestIfCmd q_obj_TestIfCmd-arg -> UserDefThree
|
||||
gen=True success_response=True boxed=False oob=False preconfig=False
|
||||
|
|
|
@ -29,6 +29,7 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
|
|||
print(' prefix %s' % prefix)
|
||||
for m in members:
|
||||
print(' member %s' % m.name)
|
||||
self._print_if(m.ifcond, indent=8)
|
||||
self._print_if(ifcond)
|
||||
|
||||
def visit_object_type(self, name, info, ifcond, base, members, variants):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue