From 28770e057f265a4e70bcbdfc2447cce7b5f2dc19 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 16 Sep 2015 13:06:24 +0200 Subject: qapi: Introduce a first class 'any' type It's first class, because unlike '**', it actually works, i.e. doesn't require 'gen': false. '**' will go away next. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Daniel P. Berrange --- tests/qapi-schema/args-any.err | 1 + tests/qapi-schema/args-any.exit | 1 + tests/qapi-schema/args-any.json | 2 ++ tests/qapi-schema/args-any.out | 0 tests/qapi-schema/flat-union-base-any.err | 1 + tests/qapi-schema/flat-union-base-any.exit | 1 + tests/qapi-schema/flat-union-base-any.json | 12 ++++++++++++ tests/qapi-schema/flat-union-base-any.out | 0 tests/qapi-schema/flat-union-base-star.err | 1 - tests/qapi-schema/flat-union-base-star.exit | 1 - tests/qapi-schema/flat-union-base-star.json | 12 ------------ tests/qapi-schema/flat-union-base-star.out | 0 tests/qapi-schema/qapi-schema-test.json | 5 ++++- tests/qapi-schema/qapi-schema-test.out | 9 ++++++++- tests/qapi-schema/type-bypass.out | 4 ++-- 15 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 tests/qapi-schema/args-any.err create mode 100644 tests/qapi-schema/args-any.exit create mode 100644 tests/qapi-schema/args-any.json create mode 100644 tests/qapi-schema/args-any.out create mode 100644 tests/qapi-schema/flat-union-base-any.err create mode 100644 tests/qapi-schema/flat-union-base-any.exit create mode 100644 tests/qapi-schema/flat-union-base-any.json create mode 100644 tests/qapi-schema/flat-union-base-any.out delete mode 100644 tests/qapi-schema/flat-union-base-star.err delete mode 100644 tests/qapi-schema/flat-union-base-star.exit delete mode 100644 tests/qapi-schema/flat-union-base-star.json delete mode 100644 tests/qapi-schema/flat-union-base-star.out (limited to 'tests/qapi-schema') diff --git a/tests/qapi-schema/args-any.err b/tests/qapi-schema/args-any.err new file mode 100644 index 0000000000..bf9b5e0730 --- /dev/null +++ b/tests/qapi-schema/args-any.err @@ -0,0 +1 @@ +tests/qapi-schema/args-any.json:2: 'data' for command 'oops' cannot use built-in type 'any' diff --git a/tests/qapi-schema/args-any.exit b/tests/qapi-schema/args-any.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/args-any.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/args-any.json b/tests/qapi-schema/args-any.json new file mode 100644 index 0000000000..58fe5e470e --- /dev/null +++ b/tests/qapi-schema/args-any.json @@ -0,0 +1,2 @@ +# we do not allow an 'any' argument +{ 'command': 'oops', 'data': 'any' } diff --git a/tests/qapi-schema/args-any.out b/tests/qapi-schema/args-any.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/flat-union-base-any.err b/tests/qapi-schema/flat-union-base-any.err new file mode 100644 index 0000000000..ad4d629e75 --- /dev/null +++ b/tests/qapi-schema/flat-union-base-any.err @@ -0,0 +1 @@ +tests/qapi-schema/flat-union-base-any.json:8: Base 'any' is not a valid struct diff --git a/tests/qapi-schema/flat-union-base-any.exit b/tests/qapi-schema/flat-union-base-any.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/flat-union-base-any.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/flat-union-base-any.json b/tests/qapi-schema/flat-union-base-any.json new file mode 100644 index 0000000000..fe66b713ef --- /dev/null +++ b/tests/qapi-schema/flat-union-base-any.json @@ -0,0 +1,12 @@ +# we require the base to be an existing struct +{ 'enum': 'TestEnum', + 'data': [ 'value1', 'value2' ] } +{ 'struct': 'TestTypeA', + 'data': { 'string': 'str' } } +{ 'struct': 'TestTypeB', + 'data': { 'integer': 'int' } } +{ 'union': 'TestUnion', + 'base': 'any', + 'discriminator': 'enum1', + 'data': { 'value1': 'TestTypeA', + 'value2': 'TestTypeB' } } diff --git a/tests/qapi-schema/flat-union-base-any.out b/tests/qapi-schema/flat-union-base-any.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/flat-union-base-star.err b/tests/qapi-schema/flat-union-base-star.err deleted file mode 100644 index b7748f08bf..0000000000 --- a/tests/qapi-schema/flat-union-base-star.err +++ /dev/null @@ -1 +0,0 @@ -tests/qapi-schema/flat-union-base-star.json:8: Base '**' is not a valid struct diff --git a/tests/qapi-schema/flat-union-base-star.exit b/tests/qapi-schema/flat-union-base-star.exit deleted file mode 100644 index d00491fd7e..0000000000 --- a/tests/qapi-schema/flat-union-base-star.exit +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/tests/qapi-schema/flat-union-base-star.json b/tests/qapi-schema/flat-union-base-star.json deleted file mode 100644 index 5099439a9d..0000000000 --- a/tests/qapi-schema/flat-union-base-star.json +++ /dev/null @@ -1,12 +0,0 @@ -# we require the base to be an existing struct -{ 'enum': 'TestEnum', - 'data': [ 'value1', 'value2' ] } -{ 'struct': 'TestTypeA', - 'data': { 'string': 'str' } } -{ 'struct': 'TestTypeB', - 'data': { 'integer': 'int' } } -{ 'union': 'TestUnion', - 'base': '**', - 'discriminator': 'enum1', - 'data': { 'value1': 'TestTypeA', - 'value2': 'TestTypeB' } } diff --git a/tests/qapi-schema/flat-union-base-star.out b/tests/qapi-schema/flat-union-base-star.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index d48815764d..6897a6ea39 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -78,7 +78,8 @@ 'number': ['number'], 'boolean': ['bool'], 'string': ['str'], - 'sizes': ['size'] } } + 'sizes': ['size'], + 'any': ['any'] } } # testing commands { 'command': 'user_def_cmd', 'data': {} } @@ -88,6 +89,8 @@ 'returns': 'UserDefTwo' } { 'command': 'user_def_cmd3', 'data': {'a': 'int', '*b': 'int' }, 'returns': 'int' } +# note: command name 'guest-sync' chosen to avoid "cannot use built-in" error +{ 'command': 'guest-sync', 'data': { 'arg': 'any' }, 'returns': 'any' } # For testing integer range flattening in opts-visitor. The following schema # corresponds to the option format: diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index f90cf4636c..a52ac31ea5 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -12,8 +12,12 @@ object :obj-__org.qemu_x-command-arg member b: __org.qemu_x-StructList optional=False member c: __org.qemu_x-Union2 optional=False member d: __org.qemu_x-Alt optional=False +object :obj-anyList-wrapper + member data: anyList optional=False object :obj-boolList-wrapper member data: boolList optional=False +object :obj-guest-sync-arg + member arg: any optional=False object :obj-int16List-wrapper member data: int16List optional=False object :obj-int32List-wrapper @@ -102,7 +106,8 @@ object UserDefNativeListUnion case boolean: :obj-boolList-wrapper case string: :obj-strList-wrapper case sizes: :obj-sizeList-wrapper -enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8', 'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'sizes'] + case any: :obj-anyList-wrapper +enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8', 'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'sizes', 'any'] object UserDefOne base UserDefZero member string: str optional=False @@ -151,6 +156,8 @@ object __org.qemu_x-Union2 case __org.qemu_x-value: __org.qemu_x-Struct2 command __org.qemu_x-command :obj-__org.qemu_x-command-arg -> __org.qemu_x-Union1 gen=True success_response=True +command guest-sync :obj-guest-sync-arg -> any + gen=True success_response=True command user_def_cmd None -> None gen=True success_response=True command user_def_cmd1 :obj-user_def_cmd1-arg -> None diff --git a/tests/qapi-schema/type-bypass.out b/tests/qapi-schema/type-bypass.out index 0070d4b845..db2a4e6d84 100644 --- a/tests/qapi-schema/type-bypass.out +++ b/tests/qapi-schema/type-bypass.out @@ -1,4 +1,4 @@ object :obj-unsafe-arg - member arg: ** optional=False -command unsafe :obj-unsafe-arg -> ** + member arg: any optional=False +command unsafe :obj-unsafe-arg -> any gen=False success_response=True -- cgit v1.2.3