Re: [Qemu-devel] [PATCH 2/2] qapi: Create an include directive for use in the JSON description files.

2014-03-26 Thread Eric Blake
On 03/26/2014 07:49 PM, Wenchao Xia wrote:
> Just saw the discuss of Lluís's patch, either
> { 'include': './include/include.json' }
> or
> include("include-cycle-b.json")
> is OK to me, but hope only one way is kepted in the end.

We already had this discussion; we want the { 'include':
'path/to/file.json' } form.


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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 2/2] qapi: Create an include directive for use in the JSON description files.

2014-03-26 Thread Eric Blake
On 03/21/2014 10:01 AM, Benoît Canet wrote:
> The new directive in the form { 'include': 'path/to/file.json' } will trigger 
> the
> parsing of path/to/file.json.
> The directive will be replaced by the result of the parsing.
> 
> This will allow for easy modularisation of qapi JSON descriptions files.
> 
> The qapi commands now takes the input file path as first argument to make it
> easier to detect include loops: stdin would not allow to do this.

It would be better to split this into two patches - one that alters the
framework to pass filenames and updates the testsuite to reflect the
improved error messages in existing tests, and the second to add the new
'include' directive with the new tests.

> 
> Signed-off-by: Benoit Canet 
> ---
>  Makefile   | 24 +--
>  scripts/qapi-commands.py   |  8 +++-
>  scripts/qapi-types.py  |  8 +++-
>  scripts/qapi-visit.py  |  8 +++-
>  scripts/qapi.py| 46 
> +-
>  tests/Makefile | 16 

Missing a change to docs/qapi-code-gen.txt.  New features require
documentation.

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 2/2] qapi: Create an include directive for use in the JSON description files.

2014-03-26 Thread Wenchao Xia

Just saw the discuss of Lluís's patch, either
{ 'include': './include/include.json' }
or
include("include-cycle-b.json")
is OK to me, but hope only one way is kepted in the end.




[Qemu-devel] [PATCH 2/2] qapi: Create an include directive for use in the JSON description files.

2014-03-21 Thread Benoît Canet
The new directive in the form { 'include': 'path/to/file.json' } will trigger 
the
parsing of path/to/file.json.
The directive will be replaced by the result of the parsing.

This will allow for easy modularisation of qapi JSON descriptions files.

The qapi commands now takes the input file path as first argument to make it
easier to detect include loops: stdin would not allow to do this.

Signed-off-by: Benoit Canet 
---
 Makefile   | 24 +--
 scripts/qapi-commands.py   |  8 +++-
 scripts/qapi-types.py  |  8 +++-
 scripts/qapi-visit.py  |  8 +++-
 scripts/qapi.py| 46 +-
 tests/Makefile | 16 
 tests/qapi-schema/duplicate-key.err|  2 +-
 .../qapi-schema/flat-union-invalid-branch-key.err  |  2 +-
 .../flat-union-invalid-discriminator.err   |  2 +-
 tests/qapi-schema/flat-union-no-base.err   |  2 +-
 .../flat-union-string-discriminator.err|  2 +-
 tests/qapi-schema/funny-char.err   |  2 +-
 tests/qapi-schema/include.err  |  0
 tests/qapi-schema/include.exit |  1 +
 tests/qapi-schema/include.json |  4 ++
 tests/qapi-schema/include.out  |  8 
 tests/qapi-schema/include/include.json |  7 
 tests/qapi-schema/include_loop.err |  0
 tests/qapi-schema/include_loop.exit|  1 +
 tests/qapi-schema/include_loop.json|  1 +
 tests/qapi-schema/include_loop.out |  1 +
 tests/qapi-schema/missing-colon.err|  2 +-
 tests/qapi-schema/missing-comma-list.err   |  2 +-
 tests/qapi-schema/missing-comma-object.err |  2 +-
 tests/qapi-schema/non-objects.err  |  2 +-
 tests/qapi-schema/quoted-structural-chars.err  |  2 +-
 tests/qapi-schema/test-qapi.py |  2 +-
 tests/qapi-schema/trailing-comma-list.err  |  2 +-
 tests/qapi-schema/trailing-comma-object.err|  2 +-
 tests/qapi-schema/unclosed-list.err|  2 +-
 tests/qapi-schema/unclosed-object.err  |  2 +-
 tests/qapi-schema/unclosed-string.err  |  2 +-
 tests/qapi-schema/union-invalid-base.err   |  2 +-
 33 files changed, 116 insertions(+), 53 deletions(-)
 create mode 100644 tests/qapi-schema/include.err
 create mode 100644 tests/qapi-schema/include.exit
 create mode 100644 tests/qapi-schema/include.json
 create mode 100644 tests/qapi-schema/include.out
 create mode 100644 tests/qapi-schema/include/include.json
 create mode 100644 tests/qapi-schema/include_loop.err
 create mode 100644 tests/qapi-schema/include_loop.exit
 create mode 100644 tests/qapi-schema/include_loop.json
 create mode 100644 tests/qapi-schema/include_loop.out

diff --git a/Makefile b/Makefile
index ec74039..9bec4ff 100644
--- a/Makefile
+++ b/Makefile
@@ -236,24 +236,24 @@ gen-out-type = $(subst .,-,$(suffix $@))
 qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
 
 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
-$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
-   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py 
$(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, "  GEN   $@")
+$(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py 
$(SRC_PATH)/qga/qapi-schema.json $(gen-out-type) -o qga/qapi-generated -p 
"qga-" < $<, "  GEN   $@")
 qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\
-$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
-   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py 
$(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, "  GEN   $@")
+$(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py 
$(SRC_PATH)/qga/qapi-schema.json $(gen-out-type) -o qga/qapi-generated -p 
"qga-" < $<, "  GEN   $@")
 qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\
-$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py 
$(qapi-py)
-   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py 
$(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, "  GEN   $@")
+$(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
+   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py 
$(SRC_PATH)/qga/qapi-schema.json $(gen-out-type) -o qga/qapi-generated -p 
"qga-" < $<, "  GEN   $@")
 
 qapi-types.c qapi-types.h :\
-$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
-   $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py 
$(gen-out-type) -o "." -b < $<, "