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.

Backports commit 26df4e7fab06422b21e11d039c64243ca4003147 from qemu
This commit is contained in:
Markus Armbruster 2018-03-09 08:02:33 -05:00 committed by Lioncash
parent b97d1f98ae
commit 8d713d6e47
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 83 additions and 68 deletions

View file

@ -170,6 +170,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
self.defn += gen_event_send(name, arg_type, boxed, self._enum_name)
self._event_names.append(name)
def main(argv):
(input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line()
blurb = ' * Schema-defined QAPI/QMP events'
@ -205,3 +206,7 @@ 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)

View file

@ -240,6 +240,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
self.decl += gen_object(name, None, [variants.tag_member], variants)
self._gen_type_cleanup(name)
def main(argv):
# If you link code generated from multiple schemata, you want only one
# instance of the code for built-in types. Generate it only when
# opt_builtins, enabled by command line option -b. See also
@ -280,3 +281,7 @@ if do_c:
genc.write(output_dir, prefix + 'qapi-types.c')
if do_h:
genh.write(output_dir, prefix + 'qapi-types.h')
if __name__ == '__main__':
main(sys.argv)

View file

@ -323,6 +323,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
self.decl += gen_visit_decl(name)
self.defn += gen_visit_alternate(name, variants)
def main(argv):
# If you link code generated from multiple schemata, you want only one
# instance of the code for built-in types. Generate it only when
# opt_builtins, enabled by command line option -b. See also
@ -367,3 +368,7 @@ if do_c:
genc.write(output_dir, prefix + 'qapi-visit.c')
if do_h:
genh.write(output_dir, prefix + 'qapi-visit.h')
if __name__ == '__main__':
main(sys.argv)