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
|
|
@ -23,6 +23,8 @@ from .gen import (
|
|||
)
|
||||
from .schema import (
|
||||
QAPISchema,
|
||||
QAPISchemaAlternatives,
|
||||
QAPISchemaBranches,
|
||||
QAPISchemaEnumMember,
|
||||
QAPISchemaFeature,
|
||||
QAPISchemaIfCond,
|
||||
|
|
@ -348,7 +350,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
|
|||
features: List[QAPISchemaFeature],
|
||||
base: Optional[QAPISchemaObjectType],
|
||||
members: List[QAPISchemaObjectTypeMember],
|
||||
variants: Optional[QAPISchemaVariants]) -> None:
|
||||
variants: Optional[QAPISchemaBranches]) -> None:
|
||||
# Nothing to do for the special empty builtin
|
||||
if name == 'q_empty':
|
||||
return
|
||||
|
|
@ -369,7 +371,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
|
|||
info: Optional[QAPISourceInfo],
|
||||
ifcond: QAPISchemaIfCond,
|
||||
features: List[QAPISchemaFeature],
|
||||
variants: QAPISchemaVariants) -> None:
|
||||
variants: QAPISchemaAlternatives) -> None:
|
||||
with ifcontext(ifcond, self._genh):
|
||||
self._genh.preamble_add(gen_fwd_object_or_array(name))
|
||||
self._genh.add(gen_object(name, ifcond, None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue