Commit 26df4e7f authored by Markus Armbruster's avatar Markus Armbruster Committed by Eric Blake
Browse files

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: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20180211093607.27351-8-armbru@redhat.com>
Reviewed-by: default avatarMichael Roth <mdroth@linux.vnet.ibm.com>
[eblake: minor tweak to keep 'blurb' one line]
Signed-off-by: default avatarEric Blake <eblake@redhat.com>
parent 93b564c4
Loading
Loading
Loading
Loading
+24 −19
Original line number Diff line number Diff line
@@ -255,6 +255,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
        self._regy += gen_register_command(name, success_response)


def main(argv):
    (input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()

    blurb = ' * Schema-defined QAPI/QMP commands'
@@ -297,3 +298,7 @@ if do_c:
        genc.write(output_dir, prefix + 'qmp-marshal.c')
    if do_h:
        genh.write(output_dir, prefix + 'qmp-commands.h')


if __name__ == '__main__':
    main(sys.argv)
+24 −19
Original line number Diff line number Diff line
@@ -171,6 +171,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
        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'
@@ -208,3 +209,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)
+30 −24
Original line number Diff line number Diff line
@@ -167,6 +167,8 @@ 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)})


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
@@ -200,3 +202,7 @@ 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)
+31 −25
Original line number Diff line number Diff line
@@ -240,6 +240,8 @@ 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 +282,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)
+34 −28
Original line number Diff line number Diff line
@@ -323,6 +323,8 @@ 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 +369,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)