mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
qapi: Rename QAPISchemaObjectType.variants to .branches
A previous commit narrowed the type of QAPISchemaObjectType.variants from QAPISchemaVariants to QAPISchemaBranches. Rename it to .branches. Same for .__init__() parameter @variants. Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
41d0ad1d04
commit
3ff2a5a35c
|
@ -64,7 +64,7 @@ def gen_call(name: str,
|
||||||
assert arg_type
|
assert arg_type
|
||||||
argstr = '&arg, '
|
argstr = '&arg, '
|
||||||
elif arg_type:
|
elif arg_type:
|
||||||
assert not arg_type.variants
|
assert not arg_type.branches
|
||||||
for memb in arg_type.members:
|
for memb in arg_type.members:
|
||||||
assert not memb.ifcond.is_present()
|
assert not memb.ifcond.is_present()
|
||||||
if memb.need_has():
|
if memb.need_has():
|
||||||
|
|
|
@ -51,7 +51,7 @@ def gen_param_var(typ: QAPISchemaObjectType) -> str:
|
||||||
|
|
||||||
Initialize it with the function arguments defined in `gen_event_send`.
|
Initialize it with the function arguments defined in `gen_event_send`.
|
||||||
"""
|
"""
|
||||||
assert not typ.variants
|
assert not typ.branches
|
||||||
ret = mcgen('''
|
ret = mcgen('''
|
||||||
%(c_name)s param = {
|
%(c_name)s param = {
|
||||||
''',
|
''',
|
||||||
|
|
|
@ -118,7 +118,7 @@ def build_params(arg_type: Optional[QAPISchemaObjectType],
|
||||||
ret += '%s arg' % arg_type.c_param_type()
|
ret += '%s arg' % arg_type.c_param_type()
|
||||||
sep = ', '
|
sep = ', '
|
||||||
elif arg_type:
|
elif arg_type:
|
||||||
assert not arg_type.variants
|
assert not arg_type.branches
|
||||||
for memb in arg_type.members:
|
for memb in arg_type.members:
|
||||||
assert not memb.ifcond.is_present()
|
assert not memb.ifcond.is_present()
|
||||||
ret += sep
|
ret += sep
|
||||||
|
|
|
@ -524,20 +524,20 @@ def __init__(
|
||||||
features: Optional[List[QAPISchemaFeature]],
|
features: Optional[List[QAPISchemaFeature]],
|
||||||
base: Optional[str],
|
base: Optional[str],
|
||||||
local_members: List[QAPISchemaObjectTypeMember],
|
local_members: List[QAPISchemaObjectTypeMember],
|
||||||
variants: Optional[QAPISchemaBranches],
|
branches: Optional[QAPISchemaBranches],
|
||||||
):
|
):
|
||||||
# struct has local_members, optional base, and no variants
|
# struct has local_members, optional base, and no branches
|
||||||
# union has base, variants, and no local_members
|
# union has base, branches, and no local_members
|
||||||
super().__init__(name, info, doc, ifcond, features)
|
super().__init__(name, info, doc, ifcond, features)
|
||||||
self.meta = 'union' if variants else 'struct'
|
self.meta = 'union' if branches else 'struct'
|
||||||
for m in local_members:
|
for m in local_members:
|
||||||
m.set_defined_in(name)
|
m.set_defined_in(name)
|
||||||
if variants is not None:
|
if branches is not None:
|
||||||
variants.set_defined_in(name)
|
branches.set_defined_in(name)
|
||||||
self._base_name = base
|
self._base_name = base
|
||||||
self.base = None
|
self.base = None
|
||||||
self.local_members = local_members
|
self.local_members = local_members
|
||||||
self.variants = variants
|
self.branches = branches
|
||||||
self.members: List[QAPISchemaObjectTypeMember]
|
self.members: List[QAPISchemaObjectTypeMember]
|
||||||
self._check_complete = False
|
self._check_complete = False
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ def check(self, schema: QAPISchema) -> None:
|
||||||
self.base = schema.resolve_type(self._base_name, self.info,
|
self.base = schema.resolve_type(self._base_name, self.info,
|
||||||
"'base'")
|
"'base'")
|
||||||
if (not isinstance(self.base, QAPISchemaObjectType)
|
if (not isinstance(self.base, QAPISchemaObjectType)
|
||||||
or self.base.variants):
|
or self.base.branches):
|
||||||
raise QAPISemError(
|
raise QAPISemError(
|
||||||
self.info,
|
self.info,
|
||||||
"'base' requires a struct type, %s isn't"
|
"'base' requires a struct type, %s isn't"
|
||||||
|
@ -577,9 +577,9 @@ def check(self, schema: QAPISchema) -> None:
|
||||||
# Cast down to the subtype.
|
# Cast down to the subtype.
|
||||||
members = cast(List[QAPISchemaObjectTypeMember], list(seen.values()))
|
members = cast(List[QAPISchemaObjectTypeMember], list(seen.values()))
|
||||||
|
|
||||||
if self.variants:
|
if self.branches:
|
||||||
self.variants.check(schema, seen)
|
self.branches.check(schema, seen)
|
||||||
self.variants.check_clash(self.info, seen)
|
self.branches.check_clash(self.info, seen)
|
||||||
|
|
||||||
self.members = members
|
self.members = members
|
||||||
self._check_complete = True # mark completed
|
self._check_complete = True # mark completed
|
||||||
|
@ -595,8 +595,8 @@ def check_clash(
|
||||||
assert self._checked
|
assert self._checked
|
||||||
for m in self.members:
|
for m in self.members:
|
||||||
m.check_clash(info, seen)
|
m.check_clash(info, seen)
|
||||||
if self.variants:
|
if self.branches:
|
||||||
self.variants.check_clash(info, seen)
|
self.branches.check_clash(info, seen)
|
||||||
|
|
||||||
def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None:
|
def connect_doc(self, doc: Optional[QAPIDoc] = None) -> None:
|
||||||
super().connect_doc(doc)
|
super().connect_doc(doc)
|
||||||
|
@ -612,7 +612,7 @@ def is_implicit(self) -> bool:
|
||||||
return self.name.startswith('q_')
|
return self.name.startswith('q_')
|
||||||
|
|
||||||
def is_empty(self) -> bool:
|
def is_empty(self) -> bool:
|
||||||
return not self.members and not self.variants
|
return not self.members and not self.branches
|
||||||
|
|
||||||
def has_conditional_members(self) -> bool:
|
def has_conditional_members(self) -> bool:
|
||||||
return any(m.ifcond.is_present() for m in self.members)
|
return any(m.ifcond.is_present() for m in self.members)
|
||||||
|
@ -635,10 +635,10 @@ def visit(self, visitor: QAPISchemaVisitor) -> None:
|
||||||
super().visit(visitor)
|
super().visit(visitor)
|
||||||
visitor.visit_object_type(
|
visitor.visit_object_type(
|
||||||
self.name, self.info, self.ifcond, self.features,
|
self.name, self.info, self.ifcond, self.features,
|
||||||
self.base, self.local_members, self.variants)
|
self.base, self.local_members, self.branches)
|
||||||
visitor.visit_object_type_flat(
|
visitor.visit_object_type_flat(
|
||||||
self.name, self.info, self.ifcond, self.features,
|
self.name, self.info, self.ifcond, self.features,
|
||||||
self.members, self.variants)
|
self.members, self.branches)
|
||||||
|
|
||||||
|
|
||||||
class QAPISchemaAlternateType(QAPISchemaType):
|
class QAPISchemaAlternateType(QAPISchemaType):
|
||||||
|
@ -1035,7 +1035,7 @@ def check(self, schema: QAPISchema) -> None:
|
||||||
"command's 'data' cannot take %s"
|
"command's 'data' cannot take %s"
|
||||||
% arg_type.describe())
|
% arg_type.describe())
|
||||||
self.arg_type = arg_type
|
self.arg_type = arg_type
|
||||||
if self.arg_type.variants and not self.boxed:
|
if self.arg_type.branches and not self.boxed:
|
||||||
raise QAPISemError(
|
raise QAPISemError(
|
||||||
self.info,
|
self.info,
|
||||||
"command's 'data' can take %s only with 'boxed': true"
|
"command's 'data' can take %s only with 'boxed': true"
|
||||||
|
@ -1103,7 +1103,7 @@ def check(self, schema: QAPISchema) -> None:
|
||||||
"event's 'data' cannot take %s"
|
"event's 'data' cannot take %s"
|
||||||
% typ.describe())
|
% typ.describe())
|
||||||
self.arg_type = typ
|
self.arg_type = typ
|
||||||
if self.arg_type.variants and not self.boxed:
|
if self.arg_type.branches and not self.boxed:
|
||||||
raise QAPISemError(
|
raise QAPISemError(
|
||||||
self.info,
|
self.info,
|
||||||
"event's 'data' can take %s only with 'boxed': true"
|
"event's 'data' can take %s only with 'boxed': true"
|
||||||
|
|
|
@ -171,7 +171,7 @@ def gen_object(name: str, ifcond: QAPISchemaIfCond,
|
||||||
if not isinstance(obj, QAPISchemaObjectType):
|
if not isinstance(obj, QAPISchemaObjectType):
|
||||||
continue
|
continue
|
||||||
ret += gen_object(obj.name, obj.ifcond, obj.base,
|
ret += gen_object(obj.name, obj.ifcond, obj.base,
|
||||||
obj.local_members, obj.variants)
|
obj.local_members, obj.branches)
|
||||||
|
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue