From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/5] qapi: Clean up documentation of alternate mappings
Date: Fri, 27 Mar 2015 12:02:51 +0100 [thread overview]
Message-ID: <87iodmn1no.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <1427328837-4406-3-git-send-email-eblake@redhat.com> (Eric Blake's message of "Wed, 25 Mar 2015 18:13:54 -0600")
Eric Blake <eblake@redhat.com> writes:
> QObject is an internal coding concept and requires the reader to
> reverse engineer the mapping; it is nicer to be explicit and call
> out specific JSON types.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> docs/qapi-code-gen.txt | 24 ++++++++++++++----------
> 1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt
> index 1f7d0ca..7fb0db7 100644
> --- a/docs/qapi-code-gen.txt
> +++ b/docs/qapi-code-gen.txt
> @@ -331,17 +331,21 @@ Resulting in this JSON object:
>
> Usage: { 'alternate: 'str', 'data': 'dict' }
>
> -An alternate type is one that allows a choice between two or more
> -QObject data types (string, integer, number, or dictionary, but not
> -array) on the wire. The definition is similar to a simple union type,
> -where each branch of the dictionary names a type, and where an
> -implicit C enum NameKind is created for the alternate Name. But
> +An alternate type is one that allows a choice between two or more JSON
> +data types on the wire. The definition is similar to a simple union
> +type, where each branch of the dictionary names a QAPI type, and where
> +an implicit C enum NameKind is created for the alternate Name. But
> unlike a union, the discriminator string is never passed on the wire
> -for QMP, instead appearing only in the generated C code. The type on
> -the wire serves an implicit discriminator, which in turn means that an
> -alternate can express a choice between a string and a single complex
> -type (passed as a dictionary), but cannot distinguish between two
> -different complex types. For example:
> +for QMP, instead appearing only in the generated C code. Rather, the
> +first byte of the value on the wire serves an implicit discriminator:
I think "first byte of" is implementation detail, and should be left
out.
> +if the branch is typed as the 'bool' built-in, it accepts true and
> +false; if it is typed as any of the various numeric built-ins, it
> +accepts a JSON number; if it is typed as a 'str' built-in or named
> +enum types it accepts a JSON string, and if it is typed as a named
> +struct or union type it accepts a JSON object. Thus, an alternate can
> +express a choice between a string and a single complex type (passed as
> +a dictionary), but cannot distinguish between two different complex
> +types or two different numeric built-in types. For example:
>
> { 'alternate': 'BlockRef',
> 'data': { 'definition': 'BlockdevOptions',
next prev parent reply other threads:[~2015-03-27 11:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 0:13 [Qemu-devel] [PATCH 0/5] qapi doc cleanups Eric Blake
2015-03-26 0:13 ` [Qemu-devel] [PATCH 1/5] qapi: Minor tweaks to qapi-code-gen.txt Eric Blake
2015-03-26 0:13 ` [Qemu-devel] [PATCH 2/5] qapi: Clean up documentation of alternate mappings Eric Blake
2015-03-27 11:02 ` Markus Armbruster [this message]
2015-03-30 15:54 ` Eric Blake
2015-03-26 0:13 ` [Qemu-devel] [PATCH 3/5] qapi: Make placeholders more obvious in doc usage statements Eric Blake
2015-03-26 0:13 ` [Qemu-devel] [PATCH 4/5] qapi: Tweak doc references to QMP when QGA is also meant Eric Blake
2015-03-26 0:13 ` [Qemu-devel] [PATCH 5/5] qapi: Fix QMP spec references to JSON Eric Blake
2015-03-27 11:05 ` [Qemu-devel] [PATCH 0/5] qapi doc cleanups Markus Armbruster
2015-05-08 14:29 ` Markus Armbruster
2015-05-08 14:41 ` Eric Blake
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=87iodmn1no.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=eblake@redhat.com \
--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.