mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
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>
This commit is contained in:
parent
248f6f62df
commit
1d067e3953
4 changed files with 38 additions and 18 deletions
|
@ -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)},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue