aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi/gen.py
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2021-02-01 14:37:43 -0500
committerMarkus Armbruster <armbru@redhat.com>2021-02-08 14:15:58 +0100
commitd921d27c1bac0765370a9b9b891f9f0429f4c7c3 (patch)
tree95d7b113dd9860aae45b1365d2cdc93dd825c1d2 /scripts/qapi/gen.py
parentfd9b1603843df86b430083b583157fe0c352901e (diff)
downloadqemu-d921d27c1bac0765370a9b9b891f9f0429f4c7c3.zip
qemu-d921d27c1bac0765370a9b9b891f9f0429f4c7c3.tar.gz
qemu-d921d27c1bac0765370a9b9b891f9f0429f4c7c3.tar.bz2
qapi/gen: Support switching to another module temporarily
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-13-jsnow@redhat.com> [Commit message tweaked]
Diffstat (limited to 'scripts/qapi/gen.py')
-rw-r--r--scripts/qapi/gen.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
index b2bb9d1..a0a5df3 100644
--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -290,6 +290,13 @@ class QAPISchemaModularCVisitor(QAPISchemaVisitor):
self._module[name] = (genc, genh)
self._current_module = name
+ @contextmanager
+ def _temp_module(self, name: str) -> Iterator[None]:
+ old_module = self._current_module
+ self._current_module = name
+ yield
+ self._current_module = old_module
+
def write(self, output_dir: str, opt_builtins: bool = False) -> None:
for name in self._module:
if QAPISchemaModule.is_builtin_module(name) and not opt_builtins: