summary refs log tree commit diff stats
path: root/scripts/qapi/gen.py
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-01-14 16:42:27 +0000
committerPeter Maydell <peter.maydell@linaro.org>2020-01-14 16:42:27 +0000
commite021e6fe5294939f286021b3f870666ccb979aa2 (patch)
tree606b0534cb354f1b82017d408b41c2ac2555f320 /scripts/qapi/gen.py
parent3a63b24a1bbf166e6f455fe43a6bbd8dea413d92 (diff)
parent3bef3aaec91815b75a78a4c12ca92ac3cec53faf (diff)
downloadfocaccia-qemu-e021e6fe5294939f286021b3f870666ccb979aa2.tar.gz
focaccia-qemu-e021e6fe5294939f286021b3f870666ccb979aa2.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-01-14' into staging
QAPI patches for 2020-01-14

# gpg: Signature made Tue 14 Jan 2020 10:15:22 GMT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2020-01-14:
  qapi: Simplify QAPISchemaModularCVisitor
  qapi: Fix code generation for empty modules
  qapi: Proper intermediate representation for modules
  qapi: Generate command registration stuff into separate files
  tests/Makefile.include: Fix missing test-qapi-emit-events.[ch]
  qapi: Tweak "command returns a nice type" check for clarity

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi/gen.py')
-rw-r--r--scripts/qapi/gen.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
index 112b6d94c5..95afae0615 100644
--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -201,10 +201,11 @@ class QAPISchemaMonolithicCVisitor(QAPISchemaVisitor):
 
 class QAPISchemaModularCVisitor(QAPISchemaVisitor):
 
-    def __init__(self, prefix, what, blurb, pydoc):
+    def __init__(self, prefix, what, user_blurb, builtin_blurb, pydoc):
         self._prefix = prefix
         self._what = what
-        self._blurb = blurb
+        self._user_blurb = user_blurb
+        self._builtin_blurb = builtin_blurb
         self._pydoc = pydoc
         self._genc = None
         self._genh = None
@@ -245,7 +246,7 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
         genc = QAPIGenC(basename + '.c', blurb, self._pydoc)
         genh = QAPIGenH(basename + '.h', blurb, self._pydoc)
         self._module[name] = (genc, genh)
-        self._set_module(name)
+        self._genc, self._genh = self._module[name]
 
     def _add_user_module(self, name, blurb):
         assert self._is_user_module(name)
@@ -256,9 +257,6 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
     def _add_system_module(self, name, blurb):
         self._add_module(name and './' + name, blurb)
 
-    def _set_module(self, name):
-        self._genc, self._genh = self._module[name]
-
     def write(self, output_dir, opt_builtins=False):
         for name in self._module:
             if self._is_builtin_module(name) and not opt_builtins:
@@ -271,15 +269,17 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
         pass
 
     def visit_module(self, name):
-        if name in self._module:
-            self._set_module(name)
-        elif self._is_builtin_module(name):
-            # The built-in module has not been created.  No code may
-            # be generated.
-            self._genc = None
-            self._genh = None
+        if name is None:
+            if self._builtin_blurb:
+                self._add_system_module(None, self._builtin_blurb)
+                self._begin_system_module(name)
+            else:
+                # The built-in module has not been created.  No code may
+                # be generated.
+                self._genc = None
+                self._genh = None
         else:
-            self._add_user_module(name, self._blurb)
+            self._add_user_module(name, self._user_blurb)
             self._begin_user_module(name)
 
     def visit_include(self, name, info):