Markus Armbruster <arm...@redhat.com> writes:

> Eric Blake <ebl...@redhat.com> writes:
>
>> On 08/04/2015 09:58 AM, Markus Armbruster wrote:
>>> 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 <arm...@redhat.com>
>>> Reviewed-by: Eric Blake <ebl...@redhat.com>
>>> ---
>>
>>> @@ -1039,8 +1040,7 @@ class QAPISchema(object):
>>>  
>>>      def _def_builtin_type(self, name, json_type, c_type, c_null):
>>>          self._def_entity(QAPISchemaBuiltinType(name, json_type, c_type, 
>>> c_null))
>>> -        if name != '**':
>>> -            self._make_array_type(name) # TODO really needed?
>>> +        self._make_array_type(name) # TODO really needed?
>>
>> Do we really want to allow ['any'] in schemata?  That would imply the
>> possibility of a 2D array.
>
> It's 2D-by-trickery.  Unlike the existing trick of wrapping the inner
> array in a struct, this one isn't visible on the wire, though.  It
> requires giving up some type checking.
>
> From a backend point of view, array of any type should just work.  We're
> already debating whether we want them under PATCH 02, so let's continue
> there.
>
>>> +++ b/tests/qapi-schema/qapi-schema-test.json
>>> @@ -83,6 +83,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' }
>>>  
>>
>> In particular, if we DO want to allow it, this file should be enhanced
>> to include ['any'] in the UserDefNativeListUnion.
>
> Yes, to keep the test case complete.

Squashing in the obvious patch (appended), R-by retained.

>> As it is, JSON allows mixed-type arrays, but all our uses of QList are
>> fixed-type (all elements share the same type); allowing an array of any
>> element may prove to be problematic.
>
> anyList is fixed-type, too: the fixed type is QObject * ;)
>
> ['any'] isn't ABI until we actually use it in an external interface.


diff --git a/tests/qapi-schema/qapi-schema-test.json 
b/tests/qapi-schema/qapi-schema-test.json
index 6665281..e855018 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -73,7 +73,8 @@
             'number': ['number'],
             'boolean': ['bool'],
             'string': ['str'],
-            'sizes': ['size'] } }
+            'sizes': ['size'],
+            'any': ['any'] } }
 
 # testing commands
 { 'command': 'user_def_cmd', 'data': {} }
diff --git a/tests/qapi-schema/qapi-schema-test.out 
b/tests/qapi-schema/qapi-schema-test.out
index 49c1197..fbb590f 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -12,6 +12,8 @@ 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
@@ -102,7 +104,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
-- 
2.4.3


Reply via email to