aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2019-11-20 19:25:50 +0100
committerMarkus Armbruster <armbru@redhat.com>2020-01-14 11:01:58 +0100
commit3e7fb5811baab213dcc7149c3aa69442d683c26c (patch)
tree4488c46b75ebf4f4746602217b51f29fc6fb5527 /tests
parenta9f1dd7ee001b645b81ad67217b582e51a44d545 (diff)
downloadqemu-3e7fb5811baab213dcc7149c3aa69442d683c26c.zip
qemu-3e7fb5811baab213dcc7149c3aa69442d683c26c.tar.gz
qemu-3e7fb5811baab213dcc7149c3aa69442d683c26c.tar.bz2
qapi: Fix code generation for empty modules
When a sub-module doesn't contain any definitions, we don't generate code for it, but we do generate the #include. We generate code only for modules that get visited. QAPISchema.visit() visits only modules that have definitions. It can visit modules multiple times. Clean this up as follows. Collect entities in their QAPISchemaModule. Have QAPISchema.visit() call QAPISchemaModule.visit() for each module. Have QAPISchemaModule.visit() call .visit_module() for itself, and QAPISchemaEntity.visit() for each of its entities. This way, we visit each module exactly once. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-6-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qapi-schema/empty.out1
-rw-r--r--tests/qapi-schema/include-repetition.out6
-rw-r--r--tests/qapi-schema/qapi-schema-test.out24
3 files changed, 13 insertions, 18 deletions
diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out
index 5b53d00..69666c3 100644
--- a/tests/qapi-schema/empty.out
+++ b/tests/qapi-schema/empty.out
@@ -9,3 +9,4 @@ enum QType
member qdict
member qlist
member qbool
+module empty.json
diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/include-repetition.out
index 5423983..0b654dd 100644
--- a/tests/qapi-schema/include-repetition.out
+++ b/tests/qapi-schema/include-repetition.out
@@ -11,15 +11,13 @@ enum QType
member qbool
module include-repetition.json
include comments.json
+include include-repetition-sub.json
+include comments.json
module comments.json
enum Status
member good
member bad
member ugly
-module include-repetition.json
-include include-repetition-sub.json
module include-repetition-sub.json
include comments.json
include comments.json
-module include-repetition.json
-include comments.json
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 3660e75..9bd3c4a 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -153,9 +153,6 @@ object q_obj_sizeList-wrapper
member data: sizeList optional=False
object q_obj_anyList-wrapper
member data: anyList optional=False
-module sub-sub-module.json
-array StatusList Status
-module qapi-schema-test.json
object q_obj_StatusList-wrapper
member data: StatusList optional=False
enum UserDefListUnionKind
@@ -193,17 +190,6 @@ object UserDefListUnion
case any: q_obj_anyList-wrapper
case user: q_obj_StatusList-wrapper
include include/sub-module.json
-module include/sub-module.json
-include sub-sub-module.json
-module sub-sub-module.json
-enum Status
- member good
- member bad
- member ugly
-module include/sub-module.json
-object SecondArrayRef
- member s: StatusList optional=False
-module qapi-schema-test.json
command user_def_cmd None -> None
gen=True success_response=True boxed=False oob=False preconfig=False
object q_obj_user_def_cmd1-arg
@@ -435,3 +421,13 @@ command test-command-cond-features3 None -> None
gen=True success_response=True boxed=False oob=False preconfig=False
feature feature1
if ['defined(TEST_IF_COND_1)', 'defined(TEST_IF_COND_2)']
+module include/sub-module.json
+include sub-sub-module.json
+object SecondArrayRef
+ member s: StatusList optional=False
+module sub-sub-module.json
+array StatusList Status
+enum Status
+ member good
+ member bad
+ member ugly