Consolidate two common sequences of clash detection into a new QAPISchemaObjectType.check_clash() helper method.
No change to generated code. Signed-off-by: Eric Blake <ebl...@redhat.com> --- v9: new patch, split off from v8 7/17 --- scripts/qapi.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 6653c70..843e364 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -980,11 +980,7 @@ class QAPISchemaObjectType(QAPISchemaType): seen = OrderedDict() if self._base_name: self.base = schema.lookup_type(self._base_name) - assert isinstance(self.base, QAPISchemaObjectType) - assert not self.base.variants # not implemented - self.base.check(schema) - for m in self.base.members: - m.check_clash(seen) + self.base.check_clash(schema, seen) for m in self.local_members: m.check(schema) m.check_clash(seen) @@ -993,6 +989,12 @@ class QAPISchemaObjectType(QAPISchemaType): self.variants.check(schema, seen) assert self.variants.tag_member in self.members + def check_clash(self, schema, seen): + self.check(schema) + assert not self.variants # not implemented + for m in self.members: + m.check_clash(seen) + def is_implicit(self): # See QAPISchema._make_implicit_object_type() return self.name[0] == ':' @@ -1071,11 +1073,7 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember): if seen: # This variant is used within a union; ensure each qapi member # field does not collide with the union's non-variant members. - assert isinstance(self.type, QAPISchemaObjectType) - assert not self.type.variants # not implemented - self.type.check(schema) - for m in self.type.members: - m.check_clash(seen) + self.type.check_clash(schema, seen) # This function exists to support ugly simple union special cases # TODO get rid of them, and drop the function -- 2.4.3