summary refs log tree commit diff stats
path: root/tests/qapi-schema/test-qapi.py
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2018-02-11 10:35:55 +0100
committerEric Blake <eblake@redhat.com>2018-03-02 13:14:10 -0600
commitcf40a0a5c2e1091846974cc8cc95a60e0b1db4af (patch)
tree151c71456ca5abe948677c8ba0c6eb4896a849ef /tests/qapi-schema/test-qapi.py
parent8a84767cc4f7e00e5dd62435c32be9e7d2cbe4d3 (diff)
downloadfocaccia-qemu-cf40a0a5c2e1091846974cc8cc95a60e0b1db4af.tar.gz
focaccia-qemu-cf40a0a5c2e1091846974cc8cc95a60e0b1db4af.zip
qapi: Record 'include' directives in intermediate representation
The include directive permits modular QAPI schemata, but the generated
code is monolithic all the same.  To permit generating modular code,
the front end needs to pass more information on inclusions to the back
ends.  The commit before last added the necessary information to the
parse tree.  This commit adds it to the intermediate representation
and its QAPISchemaVisitor.  A later commit will use this to to
generate modular code.

New entity QAPISchemaInclude represents inclusions.  Call new visitor
method visit_include() for it, so visitors can see the sub-modules a
module includes.

Note that unlike other entities, QAPISchemaInclude has no name, and is
therefore not added to entity_dict.

New QAPISchemaEntity attribute @module names the entity's source file.
Call new visitor method visit_module() when it changes during a visit,
so visitors can keep track of the module being visited.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20180211093607.27351-18-armbru@redhat.com>
[eblake: avoid accidental deletion of self._predefining]
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests/qapi-schema/test-qapi.py')
-rw-r--r--tests/qapi-schema/test-qapi.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index 4da14b43af..67e417e298 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -16,6 +16,13 @@ from qapi.common import QAPIError, QAPISchema, QAPISchemaVisitor
 
 
 class QAPISchemaTestVisitor(QAPISchemaVisitor):
+
+    def visit_module(self, name):
+        print('module %s' % name)
+
+    def visit_include(self, name, info):
+        print('include %s' % name)
+
     def visit_enum_type(self, name, info, values, prefix):
         print('enum %s %s' % (name, values))
         if prefix: