|
@@ -168,7 +168,8 @@ def gen_type_cleanup(name):
|
|
|
|
|
|
|
|
|
|
class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
|
|
class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
|
|
- def __init__(self):
|
|
|
|
|
|
+ def __init__(self, opt_builtins):
|
|
|
|
+ self._opt_builtins = opt_builtins
|
|
self.decl = None
|
|
self.decl = None
|
|
self.defn = None
|
|
self.defn = None
|
|
self._fwdecl = None
|
|
self._fwdecl = None
|
|
@@ -187,7 +188,7 @@ def visit_end(self):
|
|
self._fwdecl = None
|
|
self._fwdecl = None
|
|
# To avoid header dependency hell, we always generate
|
|
# To avoid header dependency hell, we always generate
|
|
# declarations for built-in types in our header files and
|
|
# declarations for built-in types in our header files and
|
|
- # simply guard them. See also do_builtins (command line
|
|
|
|
|
|
+ # simply guard them. See also opt_builtins (command line
|
|
# option -b).
|
|
# option -b).
|
|
self._btin += guardend('QAPI_TYPES_BUILTIN')
|
|
self._btin += guardend('QAPI_TYPES_BUILTIN')
|
|
self.decl = self._btin + self.decl
|
|
self.decl = self._btin + self.decl
|
|
@@ -202,7 +203,7 @@ def visit_enum_type(self, name, info, values, prefix):
|
|
# TODO use something cleaner than existence of info
|
|
# TODO use something cleaner than existence of info
|
|
if not info:
|
|
if not info:
|
|
self._btin += gen_enum(name, values, prefix)
|
|
self._btin += gen_enum(name, values, prefix)
|
|
- if do_builtins:
|
|
|
|
|
|
+ if self._opt_builtins:
|
|
self.defn += gen_enum_lookup(name, values, prefix)
|
|
self.defn += gen_enum_lookup(name, values, prefix)
|
|
else:
|
|
else:
|
|
self._fwdecl += gen_enum(name, values, prefix)
|
|
self._fwdecl += gen_enum(name, values, prefix)
|
|
@@ -213,7 +214,7 @@ def visit_array_type(self, name, info, element_type):
|
|
self._btin += gen_fwd_object_or_array(name)
|
|
self._btin += gen_fwd_object_or_array(name)
|
|
self._btin += gen_array(name, element_type)
|
|
self._btin += gen_array(name, element_type)
|
|
self._btin += gen_type_cleanup_decl(name)
|
|
self._btin += gen_type_cleanup_decl(name)
|
|
- if do_builtins:
|
|
|
|
|
|
+ if self._opt_builtins:
|
|
self.defn += gen_type_cleanup(name)
|
|
self.defn += gen_type_cleanup(name)
|
|
else:
|
|
else:
|
|
self._fwdecl += gen_fwd_object_or_array(name)
|
|
self._fwdecl += gen_fwd_object_or_array(name)
|
|
@@ -241,16 +242,16 @@ def visit_alternate_type(self, name, info, variants):
|
|
|
|
|
|
# If you link code generated from multiple schemata, you want only one
|
|
# If you link code generated from multiple schemata, you want only one
|
|
# instance of the code for built-in types. Generate it only when
|
|
# instance of the code for built-in types. Generate it only when
|
|
-# do_builtins, enabled by command line option -b. See also
|
|
|
|
|
|
+# opt_builtins, enabled by command line option -b. See also
|
|
# QAPISchemaGenTypeVisitor.visit_end().
|
|
# QAPISchemaGenTypeVisitor.visit_end().
|
|
-do_builtins = False
|
|
|
|
|
|
+opt_builtins = False
|
|
|
|
|
|
(input_file, output_dir, do_c, do_h, prefix, opts) = \
|
|
(input_file, output_dir, do_c, do_h, prefix, opts) = \
|
|
parse_command_line('b', ['builtins'])
|
|
parse_command_line('b', ['builtins'])
|
|
|
|
|
|
for o, a in opts:
|
|
for o, a in opts:
|
|
if o in ('-b', '--builtins'):
|
|
if o in ('-b', '--builtins'):
|
|
- do_builtins = True
|
|
|
|
|
|
+ opt_builtins = True
|
|
|
|
|
|
blurb = ' * Schema-defined QAPI types'
|
|
blurb = ' * Schema-defined QAPI types'
|
|
|
|
|
|
@@ -270,7 +271,7 @@ def visit_alternate_type(self, name, info, variants):
|
|
'''))
|
|
'''))
|
|
|
|
|
|
schema = QAPISchema(input_file)
|
|
schema = QAPISchema(input_file)
|
|
-vis = QAPISchemaGenTypeVisitor()
|
|
|
|
|
|
+vis = QAPISchemaGenTypeVisitor(opt_builtins)
|
|
schema.visit(vis)
|
|
schema.visit(vis)
|
|
genc.add(vis.defn)
|
|
genc.add(vis.defn)
|
|
genh.add(vis.decl)
|
|
genh.add(vis.decl)
|