diff options
author | Markus Armbruster | 2018-02-26 20:39:37 +0100 |
---|---|---|
committer | Eric Blake | 2018-03-02 20:14:09 +0100 |
commit | 26df4e7fab06422b21e11d039c64243ca4003147 (patch) | |
tree | 6ec019a9caa809c7b14e812829afbcb840d612b1 /scripts/qapi-introspect.py | |
parent | qapi: Reduce use of global variables in generators some (diff) | |
download | qemu-26df4e7fab06422b21e11d039c64243ca4003147.tar.gz qemu-26df4e7fab06422b21e11d039c64243ca4003147.tar.xz qemu-26df4e7fab06422b21e11d039c64243ca4003147.zip |
qapi: Turn generators into modules
The next commit will introduce a common driver program for all
generators. The generators need to be modules for that. qapi2texi.py
already is. Make the other generators follow suit.
The changes are actually trivial. Obvious in the diffs once you view
them with whitespace changes ignored.
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-8-armbru@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
[eblake: minor tweak to keep 'blurb' one line]
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts/qapi-introspect.py')
-rw-r--r-- | scripts/qapi-introspect.py | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index 5d9a7abeb8..cac219b4d8 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -167,36 +167,42 @@ const char %(c_name)s[] = %(c_string)s; arg_type = arg_type or self._schema.the_empty_object_type self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type)}) -# Debugging aid: unmask QAPI schema's type names -# We normally mask them, because they're not QMP wire ABI -opt_unmask = False -(input_file, output_dir, do_c, do_h, prefix, opts) = \ - parse_command_line('u', ['unmask-non-abi-names']) +def main(argv): + # Debugging aid: unmask QAPI schema's type names + # We normally mask them, because they're not QMP wire ABI + opt_unmask = False -for o, a in opts: - if o in ('-u', '--unmask-non-abi-names'): - opt_unmask = True + (input_file, output_dir, do_c, do_h, prefix, opts) = \ + parse_command_line('u', ['unmask-non-abi-names']) -blurb = ' * QAPI/QMP schema introspection' + for o, a in opts: + if o in ('-u', '--unmask-non-abi-names'): + opt_unmask = True -genc = QAPIGenC(blurb, __doc__) -genh = QAPIGenH(blurb, __doc__) + blurb = ' * QAPI/QMP schema introspection' -genc.add(mcgen(''' + genc = QAPIGenC(blurb, __doc__) + genh = QAPIGenH(blurb, __doc__) + + genc.add(mcgen(''' #include "qemu/osdep.h" #include "%(prefix)sqmp-introspect.h" ''', - prefix=prefix)) - -schema = QAPISchema(input_file) -vis = QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) -schema.visit(vis) -genc.add(vis.defn) -genh.add(vis.decl) - -if do_c: - genc.write(output_dir, prefix + 'qmp-introspect.c') -if do_h: - genh.write(output_dir, prefix + 'qmp-introspect.h') + prefix=prefix)) + + schema = QAPISchema(input_file) + vis = QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) + schema.visit(vis) + genc.add(vis.defn) + genh.add(vis.decl) + + if do_c: + genc.write(output_dir, prefix + 'qmp-introspect.c') + if do_h: + genh.write(output_dir, prefix + 'qmp-introspect.h') + + +if __name__ == '__main__': + main(sys.argv) |