qapi-types: Drop unnedeed ._fwdefn

Previously, the generated code in qapi-types.c initialized all
enum lookup tables first, prior to any other definitions. But
there are no topological sorting requirements that mandate this
layout, so we can drop the QAPISchemaGenTypeVisitor._fwdefn
field and just generate all definitions in visitation order.

The generated code shows some churn due to reordering, but it
is still fairly straightforward to follow (all the deletions
occur in one hunk, and all the deleted lines are re-inserted
in the same order later in the same files, just spread across
multiple insertion points).

Backports commit 0b2e84ba774651656771ed697dee8825759dffa9 from qemu
This commit is contained in:
Eric Blake 2018-02-19 21:53:42 -05:00 committed by Lioncash
parent 2ee6c960ee
commit ff1c8774ff
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -199,7 +199,6 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
self.decl = None self.decl = None
self.defn = None self.defn = None
self._fwdecl = None self._fwdecl = None
self._fwdefn = None
self._btin = None self._btin = None
def visit_begin(self, schema): def visit_begin(self, schema):
@ -212,8 +211,6 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
def visit_end(self): def visit_end(self):
self.decl = self._fwdecl + self.decl self.decl = self._fwdecl + self.decl
self._fwdecl = None self._fwdecl = None
self.defn = self._fwdefn + self.defn
self._fwdefn = 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 do_builtins (command line
@ -240,7 +237,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
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)
self._fwdefn += gen_enum_lookup(name, values, prefix) self.defn += gen_enum_lookup(name, values, prefix)
def visit_array_type(self, name, info, element_type): def visit_array_type(self, name, info, element_type):
if isinstance(element_type, QAPISchemaBuiltinType): if isinstance(element_type, QAPISchemaBuiltinType):