qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH 02/11] qapi-types.py: Implement 'base' for u


From: Eric Blake
Subject: Re: [Qemu-devel] [RFC PATCH 02/11] qapi-types.py: Implement 'base' for unions
Date: Thu, 11 Jul 2013 06:46:52 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

On 07/11/2013 05:57 AM, Eric Blake wrote:
> On 07/09/2013 03:53 AM, Kevin Wolf wrote:
>> The new 'base' key in a union definition refers to a struct type, which
>> is inlined into the union definition and can represent fields common to
>> all kinds.
> 
> Is it worth listing an example of intended use in the commit message?
> If I understand correctly, then this qapi-schema.json file:
> 
> { 'type': 'Base',
>   'data': { 'main': 'str' } }
> { 'type': 'Extra1',
>   'data': { 'foo': 'str' } }
> { 'type': 'Extra2',
>   'data': { 'bar': 'str' } }
> { 'union': 'Type',
>   'base': 'BaseType',
>   'data': { 'variant1': 'Extra1',
>             'variant2': 'Extra2' } }
> { 'command': 'test',
>   'data': { 'arg': 'Type' } }
> 
> would then be used over the wire as:
> 
> { "execute": "test",
>   "arguments": { "arg": { "type": "variant1",
>        "data": { "main": "hello", "foo": "world" } } } }
> { "execute": "test",
>   "arguments": { "arg": { "type": "variant2",
>        "data": { "main": "hi", "bar": "there" } } } }

I just read patch 6/11, and it looks like I'm a bit off; it looks like
the usage syntax with a base type is actually:

{ "execute": "test",
  "arguments": { "arg": { "type": "variant1", "main": "hello",
                          "data": { "foo": "world" } } } }
{ "execute": "test",
  "arguments": { "arg": { "type": "variant2", "main": "hi",
                          "data": { "bar": "there" } } } }

That is, a union type is automatically granted two top-level keys "type"
and "data", and a base type grants it additional top-level keys; nested
keys under "data" are still tied to just the type listed in the union.

See why a commit message can make a difference in understanding? :)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]