Received: from eggs.gnu.org ([2001:4830:134:3::10]:44033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKUmG-0007Zt-Br for qemu-devel@nongnu.org; Mon, 03 Mar 2014 10:27:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKUm8-00052s-7q for qemu-devel@nongnu.org; Mon, 03 Mar 2014 10:27:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKUm7-00052f-Vm for qemu-devel@nongnu.org; Mon, 03 Mar 2014 10:27:28 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s23FRQLP012635 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 3 Mar 2014 10:27:27 -0500 Received: from blackfin.pond.sub.org (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s23FROQM001768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 3 Mar 2014 10:27:26 -0500 From: Markus Armbruster References: <20140228155309.28087.96600.stgit@fimbulvetr.bsc.es> <20140228155321.28087.44860.stgit@fimbulvetr.bsc.es> <87eh2mgusw.fsf@blackfin.pond.sub.org> <87d2i3z7l0.fsf@fimbulvetr.bsc.es> Date: Mon, 03 Mar 2014 16:27:24 +0100 In-Reply-To: <87d2i3z7l0.fsf@fimbulvetr.bsc.es> (=?utf-8?Q?=22Llu=C3=ADs?= Vilanova"'s message of "Mon, 03 Mar 2014 15:21:15 +0100") Message-ID: <8738izxpyb.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 2/3] qapi: Add a primitive to include other files from a QAPI schema file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Llu=C3=ADs Vilanova writes: > Markus Armbruster writes: > >> Llu=C3=ADs Vilanova writes: >>> Adds the "include(...)" primitive to the syntax of QAPI schema files. >>>=20 >>> Signed-off-by: Llu=C3=ADs Vilanova >>> --- >>> docs/qapi-code-gen.txt | 8 ++++++++ >>> scripts/qapi.py | 36 ++++++++++++++++++++++++++++++++++-- >>> 2 files changed, 42 insertions(+), 2 deletions(-) >>>=20 >>> 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. >>>=20 >>> +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 sy= ntax > 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 directo= ry > >> 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 explic= it > include directory argument. What I'm not sure though is what would be a b= etter > option, having current-file-relative includes, or resuscitating the old e= xplicit > 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. >>> + >>> + >>> =3D=3D=3D Complex types =3D=3D=3D >>>=20 >>> 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 b= ranch > with stgit (and extracting that is somewhat tedious), I will redo this se= ries > 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).