mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-02 02:31:00 +00:00
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:
parent
b97d1f98ae
commit
8d713d6e47
|
@ -170,14 +170,15 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
|
|||
self.defn += gen_event_send(name, arg_type, boxed, self._enum_name)
|
||||
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-common.h"
|
||||
#include "%(prefix)sqapi-event.h"
|
||||
#include "%(prefix)sqapi-visit.h"
|
||||
|
@ -187,21 +188,25 @@ genc.add(mcgen('''
|
|||
#include "qapi/qmp-event.h"
|
||||
|
||||
''',
|
||||
prefix=prefix))
|
||||
prefix=prefix))
|
||||
|
||||
genh.add(mcgen('''
|
||||
genh.add(mcgen('''
|
||||
#include "%(prefix)sqapi-types.h"
|
||||
|
||||
''',
|
||||
prefix=prefix))
|
||||
prefix=prefix))
|
||||
|
||||
schema = QAPISchema(input_file)
|
||||
vis = QAPISchemaGenEventVisitor(prefix)
|
||||
schema.visit(vis)
|
||||
genc.add(vis.defn)
|
||||
genh.add(vis.decl)
|
||||
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 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)
|
||||
|
|
|
@ -240,43 +240,48 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
|
|||
self.decl += gen_object(name, None, [variants.tag_member], variants)
|
||||
self._gen_type_cleanup(name)
|
||||
|
||||
# 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
|
||||
# QAPISchemaGenTypeVisitor.visit_end().
|
||||
opt_builtins = False
|
||||
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
|
||||
# QAPISchemaGenTypeVisitor.visit_end().
|
||||
opt_builtins = False
|
||||
|
||||
(input_file, output_dir, do_c, do_h, prefix, opts) = \
|
||||
parse_command_line('b', ['builtins'])
|
||||
(input_file, output_dir, do_c, do_h, prefix, opts) = \
|
||||
parse_command_line('b', ['builtins'])
|
||||
|
||||
for o, a in opts:
|
||||
if o in ('-b', '--builtins'):
|
||||
opt_builtins = True
|
||||
for o, a in opts:
|
||||
if o in ('-b', '--builtins'):
|
||||
opt_builtins = True
|
||||
|
||||
blurb = ' * Schema-defined QAPI types'
|
||||
blurb = ' * Schema-defined QAPI types'
|
||||
|
||||
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 "qapi/dealloc-visitor.h"
|
||||
#include "%(prefix)sqapi-types.h"
|
||||
#include "%(prefix)sqapi-visit.h"
|
||||
''',
|
||||
prefix=prefix))
|
||||
prefix=prefix))
|
||||
|
||||
genh.add(mcgen('''
|
||||
genh.add(mcgen('''
|
||||
/* #include "qapi/util.h" */
|
||||
'''))
|
||||
|
||||
schema = QAPISchema(input_file)
|
||||
vis = QAPISchemaGenTypeVisitor(opt_builtins)
|
||||
schema.visit(vis)
|
||||
genc.add(vis.defn)
|
||||
genh.add(vis.decl)
|
||||
schema = QAPISchema(input_file)
|
||||
vis = QAPISchemaGenTypeVisitor(opt_builtins)
|
||||
schema.visit(vis)
|
||||
genc.add(vis.defn)
|
||||
genh.add(vis.decl)
|
||||
|
||||
if do_c:
|
||||
genc.write(output_dir, prefix + 'qapi-types.c')
|
||||
if do_h:
|
||||
genh.write(output_dir, prefix + 'qapi-types.h')
|
||||
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)
|
||||
|
|
|
@ -323,47 +323,52 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
|
|||
self.decl += gen_visit_decl(name)
|
||||
self.defn += gen_visit_alternate(name, variants)
|
||||
|
||||
# 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
|
||||
# QAPISchemaGenVisitVisitor.visit_end().
|
||||
opt_builtins = False
|
||||
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
|
||||
# QAPISchemaGenVisitVisitor.visit_end().
|
||||
opt_builtins = False
|
||||
|
||||
(input_file, output_dir, do_c, do_h, prefix, opts) = \
|
||||
parse_command_line('b', ['builtins'])
|
||||
(input_file, output_dir, do_c, do_h, prefix, opts) = \
|
||||
parse_command_line('b', ['builtins'])
|
||||
|
||||
for o, a in opts:
|
||||
if o in ('-b', '--builtins'):
|
||||
opt_builtins = True
|
||||
for o, a in opts:
|
||||
if o in ('-b', '--builtins'):
|
||||
opt_builtins = True
|
||||
|
||||
blurb = ' * Schema-defined QAPI visitors'
|
||||
blurb = ' * Schema-defined QAPI visitors'
|
||||
|
||||
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 "qapi/error.h"
|
||||
#include "%(prefix)sqapi-visit.h"
|
||||
''',
|
||||
prefix=prefix))
|
||||
prefix=prefix))
|
||||
|
||||
genh.add(mcgen('''
|
||||
genh.add(mcgen('''
|
||||
#include "qapi/visitor.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "%(prefix)sqapi-types.h"
|
||||
|
||||
''',
|
||||
prefix=prefix))
|
||||
prefix=prefix))
|
||||
|
||||
schema = QAPISchema(input_file)
|
||||
vis = QAPISchemaGenVisitVisitor(opt_builtins)
|
||||
schema.visit(vis)
|
||||
genc.add(vis.defn)
|
||||
genh.add(vis.decl)
|
||||
schema = QAPISchema(input_file)
|
||||
vis = QAPISchemaGenVisitVisitor(opt_builtins)
|
||||
schema.visit(vis)
|
||||
genc.add(vis.defn)
|
||||
genh.add(vis.decl)
|
||||
|
||||
if do_c:
|
||||
genc.write(output_dir, prefix + 'qapi-visit.c')
|
||||
if do_h:
|
||||
genh.write(output_dir, prefix + 'qapi-visit.h')
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue