[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 05/23] qapi: create QAPISchemaDefinition
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v4 05/23] qapi: create QAPISchemaDefinition |
Date: |
Thu, 14 Mar 2024 15:04:39 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
John Snow <jsnow@redhat.com> writes:
> On Thu, Mar 14, 2024, 5:12 AM Markus Armbruster <armbru@redhat.com> wrote:
>
>> John Snow <jsnow@redhat.com> writes:
>>
>> > Include entities don't have names, but we generally expect "entities" to
>> > have names. Reclassify all entities with names as *definitions*, leaving
>> > the nameless include entities as QAPISchemaEntity instances.
>> >
>> > This is primarily to help simplify typing around expectations of what
>> > callers expect for properties of an "entity".
>> >
>> > Suggested-by: Markus Armbruster <armbru@redhat.com>
>> > Signed-off-by: John Snow <jsnow@redhat.com>
>> > ---
>> > scripts/qapi/schema.py | 144 +++++++++++++++++++++++------------------
>> > 1 file changed, 82 insertions(+), 62 deletions(-)
>> >
>> > diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
>> > index 117f0f78f0c..da273c1649d 100644
>> > --- a/scripts/qapi/schema.py
>> > +++ b/scripts/qapi/schema.py
>>
>> [...]
>>
>> > @@ -107,6 +90,46 @@ def _set_module(self, schema, info):
>> > def set_module(self, schema):
>> > self._set_module(schema, self.info)
>> >
>> > + def visit(self, visitor):
>> > + # pylint: disable=unused-argument
>> > + assert self._checked
>> > +
>> > +
>> > +class QAPISchemaDefinition(QAPISchemaEntity):
>> > + meta: Optional[str] = None
>> > +
>> > + def __init__(self, name: str, info, doc, ifcond=None, features=None):
>> > + assert isinstance(name, str)
>> > + super().__init__(info)
>> > + for f in features or []:
>> > + assert isinstance(f, QAPISchemaFeature)
>> > + f.set_defined_in(name)
>> > + self.name = name
>> > + self.doc = doc
>> > + self._ifcond = ifcond or QAPISchemaIfCond()
>> > + self.features = features or []
>> > +
>> > + def __repr__(self):
>> > + return "<%s:%s at 0x%x>" % (type(self).__name__, self.name,
>> > + id(self))
>> > +
>> > + def c_name(self):
>> > + return c_name(self.name)
>> > +
>> > + def check(self, schema):
>> > + assert not self._checked
>> > + seen = {}
>> > + for f in self.features:
>> > + f.check_clash(self.info, seen)
>> > + super().check(schema)
>>
>> v3 called super().check() first. Why did you move it? I'm asking just
>> to make sure I'm not missing something subtle.
>>
>
> I don't believe you are, I think it was just ... something I didn't notice
> when rebasing, since I merged this patch by hand. I recall having to insert
> the super call manually, and I guess my preferences are nondeterministic.
I'd like to move it back, for consistency with its subtypes' .check(),
which all call super().check() early. Okay?
>> > +
>> > + def connect_doc(self, doc=None):
>> > + super().connect_doc(doc)
>> > + doc = doc or self.doc
>> > + if doc:
>> > + for f in self.features:
>> > + doc.connect_feature(f)
>> > +
>> > @property
>> > def ifcond(self):
>> > assert self._checked
>>
>> [...]
>>
>>
- [PATCH v4 04/23] qapi/schema: add pylint suppressions, (continued)
- [PATCH v4 04/23] qapi/schema: add pylint suppressions, John Snow, 2024/03/13
- [PATCH v4 13/23] qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type, John Snow, 2024/03/13
- [PATCH v4 02/23] qapi/parser: shush up pylint, John Snow, 2024/03/13
- [PATCH v4 12/23] qapi: use schema.resolve_type instead of schema.lookup_type, John Snow, 2024/03/13
- [PATCH v4 18/23] qapi/schema: assert inner type of QAPISchemaVariants in check_clash(), John Snow, 2024/03/13
- [PATCH v4 14/23] qapi/schema: assert info is present when necessary, John Snow, 2024/03/13
- [PATCH v4 07/23] qapi/schema: declare type for QAPISchemaArrayType.element_type, John Snow, 2024/03/13
- [PATCH v4 05/23] qapi: create QAPISchemaDefinition, John Snow, 2024/03/13
[PATCH v4 17/23] qapi/schema: fix typing for QAPISchemaVariants.tag_member, John Snow, 2024/03/13
[PATCH v4 16/23] qapi/schema: Don't initialize "members" with `None`, John Snow, 2024/03/13
[PATCH v4 22/23] qapi/schema: turn on mypy strictness, John Snow, 2024/03/13
[PATCH v4 19/23] qapi/parser: demote QAPIExpression to Dict[str, Any], John Snow, 2024/03/13
[PATCH v4 15/23] qapi/schema: add _check_complete flag, John Snow, 2024/03/13