qapi: skip redundant includes

The purpose of this change is to help create a json file containing
common definitions; each bit of generated C code must be emitted
only one time.

A second history global to all QAPISchema instances has been added
to detect when a file is included more than one time and skip these
includes.
It does not act as a stack and the changes made to it by the
__init__ function are propagated back to the caller so it's really
a global state.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
Benoît Canet 2014-05-16 12:51:56 +02:00 committed by Luiz Capitulino
parent 11b389f21e
commit 24fd848950
8 changed files with 23 additions and 5 deletions

View file

@ -193,7 +193,8 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
flat-union-string-discriminator.json \
include-simple.json include-relpath.json include-format-err.json \
include-non-file.json include-no-file.json include-before-err.json \
include-nested-err.json include-self-cycle.json include-cycle.json)
include-nested-err.json include-self-cycle.json include-cycle.json \
include-repetition.json)
GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h

View file

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

View file

View file

@ -0,0 +1 @@
0

View file

@ -0,0 +1,3 @@
{ 'include': 'comments.json' }
{ 'include': 'include-repetition-sub.json' }
{ 'include': 'comments.json' }

View file

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