From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 2/3] qapi: Add a primitive to include other files from a QAPI schema file
Date: Mon, 03 Mar 2014 16:27:24 +0100 [thread overview]
Message-ID: <8738izxpyb.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <87d2i3z7l0.fsf@fimbulvetr.bsc.es> ("Lluís Vilanova"'s message of "Mon, 03 Mar 2014 15:21:15 +0100")
Lluís Vilanova <vilanova@ac.upc.edu> writes:
> Markus Armbruster writes:
>
>> Lluís Vilanova <vilanova@ac.upc.edu> writes:
>>> Adds the "include(...)" primitive to the syntax of QAPI schema files.
>>>
>>> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
>>> ---
>>> docs/qapi-code-gen.txt | 8 ++++++++
>>> scripts/qapi.py | 36 ++++++++++++++++++++++++++++++++++--
>>> 2 files changed, 42 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt
>>> index 2e9f036..e007807 100644
>>> --- a/docs/qapi-code-gen.txt
>>> +++ b/docs/qapi-code-gen.txt
>>> @@ -40,6 +40,14 @@ enumeration types and union types.
>>> Generally speaking, types definitions should always use CamelCase
>>> for the type
>>> names. Command names should be all lower case with words separated
>>> by a hyphen.
>>>
>>> +The QAPI schema definitions can be modularized using the 'include'
>>> directive:
>>> +
>>> + include("sub-system/qapi.json")
>
>> And now it isn't JSON anymore.
>
>> To keep it JSON, use syntax like
>
>> { "include": "sub-system/qapi.json" }
>
>> If you absolutely must make it non-JSON, you better rename the .json
>> files.
>
>> Hmm, we already are non-JSON, because we use ' instead of " for no sane
>> reason.
>
>> Our JSON parser accepts ' as an extension, to save us quoting in C
>> strings. That reason doesn't apply to .json files.
>
> Is it a problem if they are not pure JSON? In the end, they are parsed by
> qapi.py (which already knows about file syntax), and having a separate syntax
> for includes makes it somewhat easier to spot when that happens.
I don't particularly care whether schema syntax is pure JSON, some
bastardized variation of JSON, or something else entirely. But as long
as we advertize schema files it as .json, they better contain JSON. If
they contain something else, they should be called something else.
>>> +
>>> +All paths are interpreted as relative to the initial input file
>>> passed to the
>>> +QAPI parsing scripts.
>
>> Really?
>
>> Consider foo.json includes lib/a.json, which wants to include
>> lib/b.json.
>
>> foo.json: include("lib/a.json")
>> lib/a.json: include("lib/b.json") # relative to foo.json's directory
>
>> Now throw in bar/bar.json including lib/a.json:
>
>> bar/bar.json: include("../lib/a.json")
>> lib/a.json: include("lib/b.json") # relative to bar/ -> ENOENT
>
>> Make it relative to the file with the include directive.
>
> Right, sorry. The documentation was not updated after removing the explicit
> include directory argument. What I'm not sure though is what would be a better
> option, having current-file-relative includes, or resuscitating the old explicit
> include argument.
Include relative to the including file is simple. If we needed
not-so-simple semantics, I suspect we'd be better off piping through
cpp.
>>> +
>>> +
>>> === Complex types ===
>>>
>>> A complex type is a dictionary containing a single key whose value is a
>> [...]
>
>> Are you aware of Wenchao Xia's "[PATCH V8 00/10] qapi script: support
>> enum as discriminator and better enum name"? I'm afraid there's a
>> (semantic?) conflict. With include files, "[PATCH V8 03/10] qapi
>> script: remember line number in schema parsing" needs to remember the
>> source file, too.
>
>> Wenchao's series is likely go in first. Perhaps you want to base on it
>> now.
>
> I was not aware of that. Since I'm managing multiple series on a single branch
> with stgit (and extracting that is somewhat tedious), I will redo this series
> once Xia's is merged upstream. Is the merge going to happen anytime soon?
I reviewed v7, and it looked almost ready to me. If v8 is ready, it'll
hopefully get merged fairly quickly (days, not weeks).
next prev parent reply other threads:[~2014-03-03 15:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-28 15:53 [Qemu-devel] [PATCH v4 0/3] qapi: Allow modularization of QAPI schema files Lluís Vilanova
2014-02-28 15:53 ` [Qemu-devel] [PATCH v4 1/3] qapi: Use an explicit input file Lluís Vilanova
2014-03-01 8:35 ` Markus Armbruster
2014-03-03 14:25 ` Lluís Vilanova
2014-03-03 15:42 ` Markus Armbruster
2014-03-03 16:59 ` Lluís Vilanova
2014-03-04 13:17 ` Markus Armbruster
2014-03-05 0:58 ` Lluís Vilanova
2014-02-28 15:53 ` [Qemu-devel] [PATCH v4 2/3] qapi: Add a primitive to include other files from a QAPI schema file Lluís Vilanova
2014-03-01 8:57 ` Markus Armbruster
2014-03-03 14:21 ` Lluís Vilanova
2014-03-03 15:27 ` Markus Armbruster [this message]
2014-03-03 17:04 ` Lluís Vilanova
2014-03-03 17:56 ` Eric Blake
2014-03-04 8:02 ` Markus Armbruster
2014-03-13 15:33 ` Benoît Canet
2014-03-13 15:54 ` Eric Blake
2014-03-13 18:05 ` Lluís Vilanova
2014-03-14 16:35 ` Benoît Canet
2014-03-14 20:24 ` Lluís Vilanova
2014-03-14 21:55 ` Benoît Canet
2014-03-17 14:20 ` Benoît Canet
2014-02-28 15:53 ` [Qemu-devel] [PATCH v4 3/3] qapi: Add tests for the "include" directive Lluís Vilanova
2014-02-28 16:18 ` [Qemu-devel] [PATCH v4 0/3] qapi: Allow modularization of QAPI schema files 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=8738izxpyb.fsf@blackfin.pond.sub.org \
--to=armbru@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.