diff options
author | Markus Armbruster <armbru@redhat.com> | 2018-02-26 13:39:37 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2018-03-02 13:14:09 -0600 |
commit | 26df4e7fab06422b21e11d039c64243ca4003147 (patch) | |
tree | 6ec019a9caa809c7b14e812829afbcb840d612b1 /scripts/qapi-event.py | |
parent | 93b564c444edc41901d0f7e922833eeb751f8249 (diff) |
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-event.py')
-rw-r--r-- | scripts/qapi-event.py | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py index f65ccdc8ea..1f8bf62c8b 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi-event.py @@ -171,14 +171,15 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor): self._event_names.append(name) -(input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line() +def main(argv): + (input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line() -blurb = ' * Schema-defined QAPI/QMP events' + blurb = ' * Schema-defined QAPI/QMP events' -genc = QAPIGenC(blurb, __doc__) -genh = QAPIGenH(blurb, __doc__) + genc = QAPIGenC(blurb, __doc__) + genh = QAPIGenH(blurb, __doc__) -genc.add(mcgen(''' + genc.add(mcgen(''' #include "qemu/osdep.h" #include "qemu-common.h" #include "%(prefix)sqapi-event.h" @@ -189,22 +190,26 @@ genc.add(mcgen(''' #include "qapi/qmp-event.h" ''', - prefix=prefix)) + prefix=prefix)) -genh.add(mcgen(''' + genh.add(mcgen(''' #include "qapi/util.h" #include "%(prefix)sqapi-types.h" ''', - prefix=prefix)) - -schema = QAPISchema(input_file) -vis = QAPISchemaGenEventVisitor(prefix) -schema.visit(vis) -genc.add(vis.defn) -genh.add(vis.decl) - -if do_c: - genc.write(output_dir, prefix + 'qapi-event.c') -if do_h: - genh.write(output_dir, prefix + 'qapi-event.h') + prefix=prefix)) + + schema = QAPISchema(input_file) + vis = QAPISchemaGenEventVisitor(prefix) + schema.visit(vis) + genc.add(vis.defn) + genh.add(vis.decl) + + if do_c: + genc.write(output_dir, prefix + 'qapi-event.c') + if do_h: + genh.write(output_dir, prefix + 'qapi-event.h') + + +if __name__ == '__main__': + main(sys.argv) |