From: Markus Armbruster <armbru@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>,
Luiz Capitulino <lcapitulino@redhat.com>,
akong@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 2/2] qapi: Allow setting default values for optional parameters
Date: Tue, 06 May 2014 13:57:24 +0200 [thread overview]
Message-ID: <87eh07yva3.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <20140506051124.GE1574@T430.nay.redhat.com> (Fam Zheng's message of "Tue, 6 May 2014 13:11:24 +0800")
Fam Zheng <famz@redhat.com> writes:
> On Mon, 05/05 21:09, Eric Blake wrote:
>> On 05/05/2014 07:30 PM, Fam Zheng wrote:
>>
>> >> NAME: { 'type': TYPE, 'default': DEFAULT }
>> >>
>> >> where
>> >>
>> >> NAME: { 'type': TYPE }
>> >>
>> >> can be abbreviated to
>> >>
>> >> NAME: TYPE
>>
>> >
>> > In data definition, we allow inline sub-structure:
>> >
>> > { 'type': 'VersionInfo',
>> > 'data': {'qemu': {'major': 'int', 'minor': 'int', 'micro': 'int'},
>> > 'package': 'str'} }
>> >
>> > If we allow properties as a dict, we need to disambiguate properly from the
>> > above case. Proposing:
>> >
>> > MAGIC: { 'name': NAME, 'type: TYPE, 'default': DEFAULT }
>>
>> Oh, good catch. The alternative is to drop all instances of inline
>> sub-structs. Searching for 'data.*{.*{', I found only VersionInfo and
>> PciBridgeInfo; I then did a full manual search of qapi-schema.json and
>> only found the additional instance of PciDeviceInfo where the sub-struct
>> is not on the same line as the initial { of the 'data'. Just getting
>> rid of inlined sub-structs may be quite feasible.
>
> Sounds good.
>
>>
>> On a related vein, there are a number of types that aren't merely a
>> string name. For example:
>>
>> { 'command': 'migrate-set-capabilities',
>> 'data': { 'capabilities': ['MigrationCapabilityStatus'] } }
>>
>> and similar, where we have an array type rather than a raw string type
>> name. But at least with that, NAME: { 'type': [ 'array' ] } is still a
>> reasonable parse.
>>
>> The problem with MAGIC:{'name'...} is that you need to express more than
>> one parameter, but as a dict, you can't reuse the same MAGIC more than
>> once. That is:
>>
>> 'data': { MAGIC : { 'name': 'qemu', 'type': { 'major'...} },
>> MAGIC : { 'name': 'package', 'type', 'str' } } }
>
> Right.
>
> Not necessarily better than dropping inline structure, just another idea:
>
> 'data' { '@arg_with_properties': { 'type': 'str' },
> '*simple_optional': 'str',
> '@optional_full': { 'type': 'int', 'default': 1 },
> 'the_most_common_form': 'bool',
> 'inline_structure': { 'major': ...} }
>
> Where '@' is a prefix for property dictionary similar to, while exclusive with,
> optional mark '*'.
If we decide to keep the '*' sigil, we can add more. Two similar
violations of the "no syntax beyond JSON" design rule aren't really
worse than one.
That said, I dislike all sigils equally :)
[...]
next prev parent reply other threads:[~2014-05-06 11:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1398764656-27534-1-git-send-email-famz@redhat.com>
[not found] ` <1398764656-27534-2-git-send-email-famz@redhat.com>
[not found] ` <535F9E40.8010407@redhat.com>
2014-05-05 8:33 ` [Qemu-devel] [PATCH v2 1/2] qapi: Allow decimal values Markus Armbruster
[not found] ` <1398764656-27534-3-git-send-email-famz@redhat.com>
[not found] ` <20140429112436.GE4835@noname.str.redhat.com>
[not found] ` <535FA06F.2060603@redhat.com>
2014-05-04 3:14 ` [Qemu-devel] [PATCH v2 2/2] qapi: Allow setting default values for optional parameters Fam Zheng
2014-05-05 9:51 ` Markus Armbruster
2014-05-05 15:13 ` Eric Blake
2014-05-05 11:06 ` Markus Armbruster
2014-05-05 15:18 ` Eric Blake
2014-05-05 17:34 ` Markus Armbruster
2014-05-05 23:03 ` Eric Blake
2014-05-06 9:55 ` Markus Armbruster
2014-05-06 12:35 ` Eric Blake
2014-05-06 15:09 ` Markus Armbruster
2014-05-06 1:30 ` Fam Zheng
2014-05-06 3:09 ` Eric Blake
2014-05-06 5:11 ` Fam Zheng
2014-05-06 11:57 ` Markus Armbruster [this message]
2014-05-06 11:53 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eh07yva3.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=akong@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.