Eric Blake <ebl...@redhat.com> writes: > 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> > > --- > v10: rebase on new Variants.check_clash() > v9: new patch, split off from v8 7/17 > --- > scripts/qapi.py | 19 ++++++++----------- > 1 file changed, 8 insertions(+), 11 deletions(-) > > diff --git a/scripts/qapi.py b/scripts/qapi.py > index 4c56935..6d8c4c7 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) > @@ -994,6 +990,12 @@ class QAPISchemaObjectType(QAPISchemaType): > assert self.variants.tag_member in self.members > self.variants.check_clash(schema, seen) > > + def check_clash(self, schema, seen): > + self.check(schema)
Do we want to hide this .check() inside .check_clash()? QAPISchemaObjectTypeMember.check() doesn't. I think the two better behave the same. > + 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] == ':' > @@ -1062,12 +1064,7 @@ class QAPISchemaObjectTypeVariants(object): > for v in self.variants: > # Reset seen map for each variant, since qapi names from one > # branch do not affect another branch > - vseen = dict(seen) > - assert isinstance(v.type, QAPISchemaObjectType) > - assert not v.type.variants # not implemented > - v.type.check(schema) > - for m in v.type.members: > - m.check_clash(vseen) > + v.type.check_clash(schema, dict(seen)) > > > class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember):