From 93b564c444edc41901d0f7e922833eeb751f8249 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 11 Feb 2018 10:35:44 +0100 Subject: qapi: Reduce use of global variables in generators some MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Eric Blake Reviewed-by: Marc-André Lureau Message-Id: <20180211093607.27351-7-armbru@redhat.com> Reviewed-by: Michael Roth Signed-off-by: Eric Blake --- scripts/qapi-introspect.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts/qapi-introspect.py') diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index 0638acda9c..5d9a7abeb8 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -41,7 +41,8 @@ def to_c_string(string): class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): - def __init__(self, unmask): + def __init__(self, prefix, unmask): + self._prefix = prefix self._unmask = unmask self.defn = None self.decl = None @@ -65,7 +66,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): # generate C # TODO can generate awfully long lines jsons.extend(self._jsons) - name = c_name(prefix, protect=False) + 'qmp_schema_json' + name = c_name(self._prefix, protect=False) + 'qmp_schema_json' self.decl = mcgen(''' extern const char %(c_name)s[]; ''', @@ -190,7 +191,7 @@ genc.add(mcgen(''' prefix=prefix)) schema = QAPISchema(input_file) -vis = QAPISchemaGenIntrospectVisitor(opt_unmask) +vis = QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) schema.visit(vis) genc.add(vis.defn) genh.add(vis.decl) -- cgit 1.4.1