diff options
author | Markus Armbruster <armbru@redhat.com> | 2019-11-20 19:25:51 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-01-14 11:01:58 +0100 |
commit | 3bef3aaec91815b75a78a4c12ca92ac3cec53faf (patch) | |
tree | 2fbba98041b5c3649d7e71f63300bc94c377cb0a /scripts/qapi/gen.py | |
parent | 3e7fb5811baab213dcc7149c3aa69442d683c26c (diff) | |
download | qemu-3bef3aaec91815b75a78a4c12ca92ac3cec53faf.zip qemu-3bef3aaec91815b75a78a4c12ca92ac3cec53faf.tar.gz qemu-3bef3aaec91815b75a78a4c12ca92ac3cec53faf.tar.bz2 |
qapi: Simplify QAPISchemaModularCVisitor
Since the previous commit, QAPISchemaVisitor.visit_module() is called
just once. Simplify QAPISchemaModularCVisitor accordingly.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20191120182551.23795-7-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts/qapi/gen.py')
-rw-r--r-- | scripts/qapi/gen.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 112b6d9..95afae0 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): |