qapi: Add a primitive to include other files from a QAPI schema file

The primitive uses JSON syntax, and include paths are relative to the file using the directive:

  { 'include': 'path/to/file.json' }

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
Lluís Vilanova 2014-05-07 20:46:15 +02:00 committed by Luiz Capitulino
parent 33aaad529e
commit a719a27c82
44 changed files with 110 additions and 13 deletions

View file

@ -0,0 +1 @@
tests/qapi-schema/include-before-err.json:2:13: Expected ":"

View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1,2 @@
{ 'include': 'include-simple-sub.json' }
{ 'command' 'missing-colon' }

View file

View file

@ -0,0 +1 @@
{ 'include': 'include-cycle-c.json' }

View file

@ -0,0 +1 @@
{ 'include': 'include-cycle.json' }

View file

@ -0,0 +1,3 @@
In file included from tests/qapi-schema/include-cycle.json:1:
In file included from include-cycle-b.json:1:
include-cycle-c.json:1: Inclusion loop for include-cycle.json

View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1 @@
{ 'include': 'include-cycle-b.json' }

View file

View file

@ -0,0 +1 @@
tests/qapi-schema/include-format-err.json:1: Invalid 'include' directive

View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1,2 @@
{ 'include': 'include-simple-sub.json',
'foo': 'bar' }

View file

View file

@ -0,0 +1,2 @@
In file included from tests/qapi-schema/include-nested-err.json:1:
missing-colon.json:1:10: Expected ":"

View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1 @@
{ 'include': 'missing-colon.json' }

View file

View file

@ -0,0 +1 @@
tests/qapi-schema/include-no-file.json:1: No such file or directory: include-no-file-sub.json

View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1 @@
{ 'include': 'include-no-file-sub.json' }

View file

View file

@ -0,0 +1 @@
tests/qapi-schema/include-non-file.json:1: Expected a file name (string), got: ['foo', 'bar']

View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1 @@
{ 'include': [ 'foo', 'bar' ] }

View file

View file

@ -0,0 +1,2 @@
{ 'enum': 'Status',
'data': [ 'good', 'bad', 'ugly' ] }

View file

View file

@ -0,0 +1 @@
0

View file

@ -0,0 +1 @@
{ 'include': 'include/relpath.json' }

View file

@ -0,0 +1,3 @@
[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
[{'enum_name': 'Status', 'enum_values': ['good', 'bad', 'ugly']}]
[]

View file

@ -0,0 +1 @@
tests/qapi-schema/include-self-cycle.json:1: Inclusion loop for include-self-cycle.json

View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1 @@
{ 'include': 'include-self-cycle.json' }

View file

View file

@ -0,0 +1,2 @@
{ 'enum': 'Status',
'data': [ 'good', 'bad', 'ugly' ] }

View file

View file

@ -0,0 +1 @@
0

View file

@ -0,0 +1 @@
{ 'include': 'include-simple-sub.json' }

View file

@ -0,0 +1,3 @@
[OrderedDict([('enum', 'Status'), ('data', ['good', 'bad', 'ugly'])])]
[{'enum_name': 'Status', 'enum_values': ['good', 'bad', 'ugly']}]
[]

View file

@ -0,0 +1 @@
{ 'include': '../include-relpath-sub.json' }