diff options
author | Markus Armbruster <armbru@redhat.com> | 2018-02-11 10:35:44 +0100 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2018-03-02 13:14:09 -0600 |
commit | 93b564c444edc41901d0f7e922833eeb751f8249 (patch) | |
tree | af0b36e50877b556dcf2b16c2094586af51ff881 /scripts/qapi-commands.py | |
parent | 47a6ea9aab1d857015684cda387ffba05a036721 (diff) |
qapi: Reduce use of global variables in generators some
In preparation of the next commit, which will turn the generators into
modules. These global variables will become local to main() then.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20180211093607.27351-7-armbru@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts/qapi-commands.py')
-rw-r--r-- | scripts/qapi-commands.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index 8435a890ba..e75e32e489 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -207,7 +207,7 @@ def gen_register_command(name, success_response): return ret -def gen_registry(registry): +def gen_registry(registry, prefix): ret = mcgen(''' void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds) @@ -224,7 +224,8 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds) class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): - def __init__(self): + def __init__(self, prefix): + self._prefix = prefix self.decl = None self.defn = None self._regy = None @@ -237,7 +238,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): self._visited_ret_types = set() def visit_end(self): - self.defn += gen_registry(self._regy) + self.defn += gen_registry(self._regy, self._prefix) self._regy = None self._visited_ret_types = None @@ -287,7 +288,7 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); prefix=prefix, c_prefix=c_name(prefix, protect=False))) schema = QAPISchema(input_file) -vis = QAPISchemaGenCommandVisitor() +vis = QAPISchemaGenCommandVisitor(prefix) schema.visit(vis) genc.add(vis.defn) genh.add(vis.decl) |