qapi: Rename visitor parameter @variants to @alternatives
A previous commit narrowed the type of .visit_alternate_type() parameter @variants from QAPISchemaVariants to QAPISchemaAlternatives. Rename it to @alternatives. One of them passes @alternatives to helper function gen_visit_alternate(). Rename its @variants parameter to @alternatives as well. Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
d1da8af897
commit
41d0ad1d04
@ -318,7 +318,8 @@ class QAPISchemaGenRSTVisitor(QAPISchemaVisitor):
|
||||
+ self._nodes_for_sections(doc)
|
||||
+ self._nodes_for_if_section(ifcond))
|
||||
|
||||
def visit_alternate_type(self, name, info, ifcond, features, variants):
|
||||
def visit_alternate_type(self, name, info, ifcond, features,
|
||||
alternatives):
|
||||
doc = self._cur_doc
|
||||
self._add_doc('Alternate',
|
||||
self._nodes_for_members(doc, 'Members')
|
||||
|
@ -348,12 +348,12 @@ const QLitObject %(c_name)s = %(c_string)s;
|
||||
def visit_alternate_type(self, name: str, info: Optional[QAPISourceInfo],
|
||||
ifcond: QAPISchemaIfCond,
|
||||
features: List[QAPISchemaFeature],
|
||||
variants: QAPISchemaAlternatives) -> None:
|
||||
alternatives: QAPISchemaAlternatives) -> None:
|
||||
self._gen_tree(
|
||||
name, 'alternate',
|
||||
{'members': [Annotated({'type': self._use_type(m.type)},
|
||||
m.ifcond)
|
||||
for m in variants.variants]},
|
||||
for m in alternatives.variants]},
|
||||
ifcond, features
|
||||
)
|
||||
|
||||
|
@ -236,7 +236,7 @@ class QAPISchemaVisitor:
|
||||
info: Optional[QAPISourceInfo],
|
||||
ifcond: QAPISchemaIfCond,
|
||||
features: List[QAPISchemaFeature],
|
||||
variants: QAPISchemaAlternatives,
|
||||
alternatives: QAPISchemaAlternatives,
|
||||
) -> None:
|
||||
pass
|
||||
|
||||
|
@ -371,11 +371,11 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
|
||||
info: Optional[QAPISourceInfo],
|
||||
ifcond: QAPISchemaIfCond,
|
||||
features: List[QAPISchemaFeature],
|
||||
variants: QAPISchemaAlternatives) -> None:
|
||||
alternatives: 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,
|
||||
[variants.tag_member], variants))
|
||||
[alternatives.tag_member], alternatives))
|
||||
with ifcontext(ifcond, self._genh, self._genc):
|
||||
self._gen_type_cleanup(name)
|
||||
|
||||
|
@ -223,7 +223,8 @@ bool visit_type_%(c_name)s(Visitor *v, const char *name,
|
||||
c_name=c_name(name))
|
||||
|
||||
|
||||
def gen_visit_alternate(name: str, variants: QAPISchemaAlternatives) -> str:
|
||||
def gen_visit_alternate(name: str,
|
||||
alternatives: QAPISchemaAlternatives) -> str:
|
||||
ret = mcgen('''
|
||||
|
||||
bool visit_type_%(c_name)s(Visitor *v, const char *name,
|
||||
@ -245,7 +246,7 @@ bool visit_type_%(c_name)s(Visitor *v, const char *name,
|
||||
''',
|
||||
c_name=c_name(name))
|
||||
|
||||
for var in variants.variants:
|
||||
for var in alternatives.variants:
|
||||
ret += var.ifcond.gen_if()
|
||||
ret += mcgen('''
|
||||
case %(case)s:
|
||||
@ -414,10 +415,10 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
||||
info: Optional[QAPISourceInfo],
|
||||
ifcond: QAPISchemaIfCond,
|
||||
features: List[QAPISchemaFeature],
|
||||
variants: QAPISchemaAlternatives) -> None:
|
||||
alternatives: QAPISchemaAlternatives) -> None:
|
||||
with ifcontext(ifcond, self._genh, self._genc):
|
||||
self._genh.add(gen_visit_decl(name))
|
||||
self._genc.add(gen_visit_alternate(name, variants))
|
||||
self._genc.add(gen_visit_alternate(name, alternatives))
|
||||
|
||||
|
||||
def gen_visit(schema: QAPISchema,
|
||||
|
@ -61,9 +61,10 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
|
||||
self._print_if(ifcond)
|
||||
self._print_features(features)
|
||||
|
||||
def visit_alternate_type(self, name, info, ifcond, features, variants):
|
||||
def visit_alternate_type(self, name, info, ifcond, features,
|
||||
alternatives):
|
||||
print('alternate %s' % name)
|
||||
self._print_variants(variants)
|
||||
self._print_variants(alternatives)
|
||||
self._print_if(ifcond)
|
||||
self._print_features(features)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user