[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 06/28] qapi: Add some union tests
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v5 06/28] qapi: Add some union tests |
Date: |
Tue, 31 Mar 2015 12:31:11 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
On 03/31/2015 12:15 PM, Eric Blake wrote:
>>> Cool. Or more concretely,
>>>
>>> { 'union': 'Simple', 'data': { 'one': 'str', 'two': 'int' } }
>>>
>>> is identical on the wire to:
>>>
>>> { 'enum': 'MyEnum', 'data': ['one', 'two'] }
>>> { 'type': 'Base', 'data': { 'type': 'MyEnum' } }
>>> { 'type': 'Branch1', 'data': { 'data': 'str' } }
>>> { 'type': 'Branch2', 'data': { 'data': 'int' } }
>>> { 'union': 'Flat', 'base': 'Base', 'discriminator': 'type',
>>> 'data': { 'one': 'Branch1', 'two': 'Branch2' } }
>>
>> Perhaps we should expose all unions for schema introspection in a way
>> similar to this (possibly not splitting out Branch1 and Branch2 as
>> independent types, though). We would just have to give a name to
>> implicitly generated enums and base types.
>
> So maybe we update the schema to allow anonymous types. That is:
>
> { 'union': 'Simple',
> 'data': { 'one': { 'name': 'str', 'value': 'int' } } }
>
> would be nicer than the current requirement of:
>
> { 'type': 'Branch1', 'data': { 'name': 'str', 'value': 'int' } }
> { 'union': 'Simple',
> 'data': { 'one': 'Branch1' } }
Hmm; maybe we could support a notion of a 'common' dictionary for simple
unions, containing all non-discriminator fields present in all branches,
where (using anonymous types for compactness), and assuming the enum
definition:
{ 'union': 'Simple',
'common': { 'readonly': 'bool' },
'data': { 'one': 'str', 'two': 'int' } }
is shorthand for:
{ 'union': 'Flat',
'base': { 'readonly': 'bool', 'type': 'Enum' },
'discriminator': 'type',
'data': { 'one': { 'data': 'str' },
'two': { 'data': 'int' } } }
that is, where 'base' for flat unions is the union of the 'common' type
and 'discriminator':'discriminator-type' member of simple unions.
At any rate, any changes along these lines will be a later series. Time
for me to get back to work on publishing v6 :)
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v5 15/28] qapi: Add tests of redefined expressions, (continued)
Re: [Qemu-devel] [PATCH v5 06/28] qapi: Add some union tests, Markus Armbruster, 2015/03/26
[Qemu-devel] [PATCH v5 26/28] qapi: Drop inline nested type in query-version, Eric Blake, 2015/03/24
[Qemu-devel] [PATCH v5 22/28] qapi: Whitelist commands that don't return dictionary, Eric Blake, 2015/03/24