diff options
| author | Markus Armbruster <armbru@redhat.com> | 2024-03-15 20:32:41 +0100 |
|---|---|---|
| committer | Markus Armbruster <armbru@redhat.com> | 2024-05-06 12:38:27 +0200 |
| commit | 1d067e3953e76af28ba20c995b176fcbcb7a10aa (patch) | |
| tree | e786d595fe7beb4ff37a9a783d1fb2338ded537b /scripts/qapi/introspect.py | |
| parent | 248f6f62df073a3b4158fd0093863ab885feabb5 (diff) | |
| download | focaccia-qemu-1d067e3953e76af28ba20c995b176fcbcb7a10aa.tar.gz focaccia-qemu-1d067e3953e76af28ba20c995b176fcbcb7a10aa.zip | |
qapi: New QAPISchemaBranches, QAPISchemaAlternatives
QAPISchemaVariants represents either a union type's branches, or an alternate type's alternatives. Much of its code is conditional on which one it actually is. Create QAPISchemaBranches for branches, and QAPISchemaAlternatives for alternatives, both subtypes of QAPISchemaVariants. Replace QAPISchemaVariants by one of them where possible. Keep it only where we actually deal with either of them. QAPISchemaVariants.__init__() takes @tag_name and @tag_member, where exactly one must be None: @tag_name for alternatives, @tag_member for branches. Let QAPISchemaBranches.__init__() take just @tag_name, and QAPISchemaAlternatives.__init__() take just @tag_member. A later patch will move the conditional code to the subtypes. Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts/qapi/introspect.py')
| -rw-r--r-- | scripts/qapi/introspect.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 4679b1bc2c..b866517942 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -26,6 +26,8 @@ from .common import c_name, mcgen from .gen import QAPISchemaMonolithicCVisitor from .schema import ( QAPISchema, + QAPISchemaAlternatives, + QAPISchemaBranches, QAPISchemaArrayType, QAPISchemaBuiltinType, QAPISchemaEntity, @@ -36,7 +38,6 @@ from .schema import ( QAPISchemaObjectTypeMember, QAPISchemaType, QAPISchemaVariant, - QAPISchemaVariants, ) from .source import QAPISourceInfo @@ -335,7 +336,7 @@ const QLitObject %(c_name)s = %(c_string)s; ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], members: List[QAPISchemaObjectTypeMember], - variants: Optional[QAPISchemaVariants]) -> None: + variants: Optional[QAPISchemaBranches]) -> None: obj: SchemaInfoObject = { 'members': [self._gen_object_member(m) for m in members] } @@ -347,7 +348,7 @@ const QLitObject %(c_name)s = %(c_string)s; def visit_alternate_type(self, name: str, info: Optional[QAPISourceInfo], ifcond: QAPISchemaIfCond, features: List[QAPISchemaFeature], - variants: QAPISchemaVariants) -> None: + variants: QAPISchemaAlternatives) -> None: self._gen_tree( name, 'alternate', {'members': [Annotated({'type': self._use_type(m.type)}, |