mirror of https://github.com/xemu-project/xemu.git
qapi: wrap Sequence[str] in an object
Mechanical change, except for a new assertion in QAPISchemaEntity.ifcond(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20210804083105.97531-3-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Rebased with obvious conflicts, commit message adjusted] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
3248c1aaf2
commit
f17539c80d
|
@ -116,7 +116,7 @@ class QAPISchemaGenRSTVisitor(QAPISchemaVisitor):
|
||||||
the conditions are in literal-text and the commas are not.
|
the conditions are in literal-text and the commas are not.
|
||||||
If with_if is False, we don't return the "(If: " and ")".
|
If with_if is False, we don't return the "(If: " and ")".
|
||||||
"""
|
"""
|
||||||
condlist = intersperse([nodes.literal('', c) for c in ifcond],
|
condlist = intersperse([nodes.literal('', c) for c in ifcond.ifcond],
|
||||||
nodes.Text(', '))
|
nodes.Text(', '))
|
||||||
if not with_if:
|
if not with_if:
|
||||||
return condlist
|
return condlist
|
||||||
|
@ -139,7 +139,7 @@ class QAPISchemaGenRSTVisitor(QAPISchemaVisitor):
|
||||||
term.append(nodes.literal('', member.type.doc_type()))
|
term.append(nodes.literal('', member.type.doc_type()))
|
||||||
if member.optional:
|
if member.optional:
|
||||||
term.append(nodes.Text(' (optional)'))
|
term.append(nodes.Text(' (optional)'))
|
||||||
if member.ifcond:
|
if member.ifcond.ifcond:
|
||||||
term.extend(self._nodes_for_ifcond(member.ifcond))
|
term.extend(self._nodes_for_ifcond(member.ifcond))
|
||||||
return term
|
return term
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ class QAPISchemaGenRSTVisitor(QAPISchemaVisitor):
|
||||||
nodes.literal('', variants.tag_member.name),
|
nodes.literal('', variants.tag_member.name),
|
||||||
nodes.Text(' is '),
|
nodes.Text(' is '),
|
||||||
nodes.literal('', '"%s"' % variant.name)]
|
nodes.literal('', '"%s"' % variant.name)]
|
||||||
if variant.ifcond:
|
if variant.ifcond.ifcond:
|
||||||
term.extend(self._nodes_for_ifcond(variant.ifcond))
|
term.extend(self._nodes_for_ifcond(variant.ifcond))
|
||||||
return term
|
return term
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ class QAPISchemaGenRSTVisitor(QAPISchemaVisitor):
|
||||||
dlnode = nodes.definition_list()
|
dlnode = nodes.definition_list()
|
||||||
for section in doc.args.values():
|
for section in doc.args.values():
|
||||||
termtext = [nodes.literal('', section.member.name)]
|
termtext = [nodes.literal('', section.member.name)]
|
||||||
if section.member.ifcond:
|
if section.member.ifcond.ifcond:
|
||||||
termtext.extend(self._nodes_for_ifcond(section.member.ifcond))
|
termtext.extend(self._nodes_for_ifcond(section.member.ifcond))
|
||||||
# TODO drop fallbacks when undocumented members are outlawed
|
# TODO drop fallbacks when undocumented members are outlawed
|
||||||
if section.text:
|
if section.text:
|
||||||
|
@ -277,7 +277,7 @@ class QAPISchemaGenRSTVisitor(QAPISchemaVisitor):
|
||||||
def _nodes_for_if_section(self, ifcond):
|
def _nodes_for_if_section(self, ifcond):
|
||||||
"""Return list of doctree nodes for the "If" section"""
|
"""Return list of doctree nodes for the "If" section"""
|
||||||
nodelist = []
|
nodelist = []
|
||||||
if ifcond:
|
if ifcond.ifcond:
|
||||||
snode = self._make_section('If')
|
snode = self._make_section('If')
|
||||||
snode += nodes.paragraph(
|
snode += nodes.paragraph(
|
||||||
'', '', *self._nodes_for_ifcond(ifcond, with_if=False)
|
'', '', *self._nodes_for_ifcond(ifcond, with_if=False)
|
||||||
|
|
|
@ -17,7 +17,6 @@ from typing import (
|
||||||
Dict,
|
Dict,
|
||||||
List,
|
List,
|
||||||
Optional,
|
Optional,
|
||||||
Sequence,
|
|
||||||
Set,
|
Set,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,6 +30,7 @@ from .gen import (
|
||||||
from .schema import (
|
from .schema import (
|
||||||
QAPISchema,
|
QAPISchema,
|
||||||
QAPISchemaFeature,
|
QAPISchemaFeature,
|
||||||
|
QAPISchemaIfCond,
|
||||||
QAPISchemaObjectType,
|
QAPISchemaObjectType,
|
||||||
QAPISchemaType,
|
QAPISchemaType,
|
||||||
)
|
)
|
||||||
|
@ -301,7 +301,7 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds)
|
||||||
def visit_command(self,
|
def visit_command(self,
|
||||||
name: str,
|
name: str,
|
||||||
info: Optional[QAPISourceInfo],
|
info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
arg_type: Optional[QAPISchemaObjectType],
|
arg_type: Optional[QAPISchemaObjectType],
|
||||||
ret_type: Optional[QAPISchemaType],
|
ret_type: Optional[QAPISchemaType],
|
||||||
|
|
|
@ -12,7 +12,7 @@ This work is licensed under the terms of the GNU GPL, version 2.
|
||||||
See the COPYING file in the top-level directory.
|
See the COPYING file in the top-level directory.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import List, Optional, Sequence
|
from typing import List, Optional
|
||||||
|
|
||||||
from .common import c_enum_const, c_name, mcgen
|
from .common import c_enum_const, c_name, mcgen
|
||||||
from .gen import QAPISchemaModularCVisitor, build_params, ifcontext
|
from .gen import QAPISchemaModularCVisitor, build_params, ifcontext
|
||||||
|
@ -20,6 +20,7 @@ from .schema import (
|
||||||
QAPISchema,
|
QAPISchema,
|
||||||
QAPISchemaEnumMember,
|
QAPISchemaEnumMember,
|
||||||
QAPISchemaFeature,
|
QAPISchemaFeature,
|
||||||
|
QAPISchemaIfCond,
|
||||||
QAPISchemaObjectType,
|
QAPISchemaObjectType,
|
||||||
)
|
)
|
||||||
from .source import QAPISourceInfo
|
from .source import QAPISourceInfo
|
||||||
|
@ -227,7 +228,7 @@ void %(event_emit)s(%(event_enum)s event, QDict *qdict);
|
||||||
def visit_event(self,
|
def visit_event(self,
|
||||||
name: str,
|
name: str,
|
||||||
info: Optional[QAPISourceInfo],
|
info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
arg_type: Optional[QAPISchemaObjectType],
|
arg_type: Optional[QAPISchemaObjectType],
|
||||||
boxed: bool) -> None:
|
boxed: bool) -> None:
|
||||||
|
|
|
@ -18,7 +18,6 @@ from typing import (
|
||||||
Dict,
|
Dict,
|
||||||
Iterator,
|
Iterator,
|
||||||
Optional,
|
Optional,
|
||||||
Sequence,
|
|
||||||
Tuple,
|
Tuple,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,6 +31,7 @@ from .common import (
|
||||||
mcgen,
|
mcgen,
|
||||||
)
|
)
|
||||||
from .schema import (
|
from .schema import (
|
||||||
|
QAPISchemaIfCond,
|
||||||
QAPISchemaModule,
|
QAPISchemaModule,
|
||||||
QAPISchemaObjectType,
|
QAPISchemaObjectType,
|
||||||
QAPISchemaVisitor,
|
QAPISchemaVisitor,
|
||||||
|
@ -85,7 +85,7 @@ class QAPIGen:
|
||||||
fp.write(text)
|
fp.write(text)
|
||||||
|
|
||||||
|
|
||||||
def _wrap_ifcond(ifcond: Sequence[str], before: str, after: str) -> str:
|
def _wrap_ifcond(ifcond: QAPISchemaIfCond, before: str, after: str) -> str:
|
||||||
if before == after:
|
if before == after:
|
||||||
return after # suppress empty #if ... #endif
|
return after # suppress empty #if ... #endif
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ def _wrap_ifcond(ifcond: Sequence[str], before: str, after: str) -> str:
|
||||||
if added[0] == '\n':
|
if added[0] == '\n':
|
||||||
out += '\n'
|
out += '\n'
|
||||||
added = added[1:]
|
added = added[1:]
|
||||||
out += gen_if(ifcond)
|
out += gen_if(ifcond.ifcond)
|
||||||
out += added
|
out += added
|
||||||
out += gen_endif(ifcond)
|
out += gen_endif(ifcond.ifcond)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,9 +127,9 @@ def build_params(arg_type: Optional[QAPISchemaObjectType],
|
||||||
class QAPIGenCCode(QAPIGen):
|
class QAPIGenCCode(QAPIGen):
|
||||||
def __init__(self, fname: str):
|
def __init__(self, fname: str):
|
||||||
super().__init__(fname)
|
super().__init__(fname)
|
||||||
self._start_if: Optional[Tuple[Sequence[str], str, str]] = None
|
self._start_if: Optional[Tuple[QAPISchemaIfCond, str, str]] = None
|
||||||
|
|
||||||
def start_if(self, ifcond: Sequence[str]) -> None:
|
def start_if(self, ifcond: QAPISchemaIfCond) -> None:
|
||||||
assert self._start_if is None
|
assert self._start_if is None
|
||||||
self._start_if = (ifcond, self._body, self._preamble)
|
self._start_if = (ifcond, self._body, self._preamble)
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ class QAPIGenH(QAPIGenC):
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def ifcontext(ifcond: Sequence[str], *args: QAPIGenCCode) -> Iterator[None]:
|
def ifcontext(ifcond: QAPISchemaIfCond, *args: QAPIGenCCode) -> Iterator[None]:
|
||||||
"""
|
"""
|
||||||
A with-statement context manager that wraps with `start_if()` / `end_if()`.
|
A with-statement context manager that wraps with `start_if()` / `end_if()`.
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,9 @@ from typing import (
|
||||||
Any,
|
Any,
|
||||||
Dict,
|
Dict,
|
||||||
Generic,
|
Generic,
|
||||||
Iterable,
|
|
||||||
List,
|
List,
|
||||||
Optional,
|
Optional,
|
||||||
Sequence,
|
Sequence,
|
||||||
Tuple,
|
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
|
@ -38,6 +36,7 @@ from .schema import (
|
||||||
QAPISchemaEntity,
|
QAPISchemaEntity,
|
||||||
QAPISchemaEnumMember,
|
QAPISchemaEnumMember,
|
||||||
QAPISchemaFeature,
|
QAPISchemaFeature,
|
||||||
|
QAPISchemaIfCond,
|
||||||
QAPISchemaObjectType,
|
QAPISchemaObjectType,
|
||||||
QAPISchemaObjectTypeMember,
|
QAPISchemaObjectTypeMember,
|
||||||
QAPISchemaType,
|
QAPISchemaType,
|
||||||
|
@ -91,11 +90,11 @@ class Annotated(Generic[_ValueT]):
|
||||||
"""
|
"""
|
||||||
# TODO: Remove after Python 3.7 adds @dataclass:
|
# TODO: Remove after Python 3.7 adds @dataclass:
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
def __init__(self, value: _ValueT, ifcond: Iterable[str],
|
def __init__(self, value: _ValueT, ifcond: QAPISchemaIfCond,
|
||||||
comment: Optional[str] = None):
|
comment: Optional[str] = None):
|
||||||
self.value = value
|
self.value = value
|
||||||
self.comment: Optional[str] = comment
|
self.comment: Optional[str] = comment
|
||||||
self.ifcond: Tuple[str, ...] = tuple(ifcond)
|
self.ifcond = ifcond
|
||||||
|
|
||||||
|
|
||||||
def _tree_to_qlit(obj: JSONValue,
|
def _tree_to_qlit(obj: JSONValue,
|
||||||
|
@ -124,11 +123,11 @@ def _tree_to_qlit(obj: JSONValue,
|
||||||
ret = ''
|
ret = ''
|
||||||
if obj.comment:
|
if obj.comment:
|
||||||
ret += indent(level) + f"/* {obj.comment} */\n"
|
ret += indent(level) + f"/* {obj.comment} */\n"
|
||||||
if obj.ifcond:
|
if obj.ifcond.ifcond:
|
||||||
ret += gen_if(obj.ifcond)
|
ret += gen_if(obj.ifcond.ifcond)
|
||||||
ret += _tree_to_qlit(obj.value, level)
|
ret += _tree_to_qlit(obj.value, level)
|
||||||
if obj.ifcond:
|
if obj.ifcond.ifcond:
|
||||||
ret += '\n' + gen_endif(obj.ifcond)
|
ret += '\n' + gen_endif(obj.ifcond.ifcond)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
ret = ''
|
ret = ''
|
||||||
|
@ -254,7 +253,7 @@ const QLitObject %(c_name)s = %(c_string)s;
|
||||||
return [Annotated(f.name, f.ifcond) for f in features]
|
return [Annotated(f.name, f.ifcond) for f in features]
|
||||||
|
|
||||||
def _gen_tree(self, name: str, mtype: str, obj: Dict[str, object],
|
def _gen_tree(self, name: str, mtype: str, obj: Dict[str, object],
|
||||||
ifcond: Sequence[str] = (),
|
ifcond: QAPISchemaIfCond = QAPISchemaIfCond(),
|
||||||
features: Sequence[QAPISchemaFeature] = ()) -> None:
|
features: Sequence[QAPISchemaFeature] = ()) -> None:
|
||||||
"""
|
"""
|
||||||
Build and append a SchemaInfo object to self._trees.
|
Build and append a SchemaInfo object to self._trees.
|
||||||
|
@ -305,7 +304,7 @@ const QLitObject %(c_name)s = %(c_string)s;
|
||||||
self._gen_tree(name, 'builtin', {'json-type': json_type})
|
self._gen_tree(name, 'builtin', {'json-type': json_type})
|
||||||
|
|
||||||
def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo],
|
def visit_enum_type(self, name: str, info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
members: List[QAPISchemaEnumMember],
|
members: List[QAPISchemaEnumMember],
|
||||||
prefix: Optional[str]) -> None:
|
prefix: Optional[str]) -> None:
|
||||||
|
@ -316,14 +315,14 @@ const QLitObject %(c_name)s = %(c_string)s;
|
||||||
)
|
)
|
||||||
|
|
||||||
def visit_array_type(self, name: str, info: Optional[QAPISourceInfo],
|
def visit_array_type(self, name: str, info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
element_type: QAPISchemaType) -> None:
|
element_type: QAPISchemaType) -> None:
|
||||||
element = self._use_type(element_type)
|
element = self._use_type(element_type)
|
||||||
self._gen_tree('[' + element + ']', 'array', {'element-type': element},
|
self._gen_tree('[' + element + ']', 'array', {'element-type': element},
|
||||||
ifcond)
|
ifcond)
|
||||||
|
|
||||||
def visit_object_type_flat(self, name: str, info: Optional[QAPISourceInfo],
|
def visit_object_type_flat(self, name: str, info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
members: List[QAPISchemaObjectTypeMember],
|
members: List[QAPISchemaObjectTypeMember],
|
||||||
variants: Optional[QAPISchemaVariants]) -> None:
|
variants: Optional[QAPISchemaVariants]) -> None:
|
||||||
|
@ -336,7 +335,7 @@ const QLitObject %(c_name)s = %(c_string)s;
|
||||||
self._gen_tree(name, 'object', obj, ifcond, features)
|
self._gen_tree(name, 'object', obj, ifcond, features)
|
||||||
|
|
||||||
def visit_alternate_type(self, name: str, info: Optional[QAPISourceInfo],
|
def visit_alternate_type(self, name: str, info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
variants: QAPISchemaVariants) -> None:
|
variants: QAPISchemaVariants) -> None:
|
||||||
self._gen_tree(
|
self._gen_tree(
|
||||||
|
@ -348,7 +347,7 @@ const QLitObject %(c_name)s = %(c_string)s;
|
||||||
)
|
)
|
||||||
|
|
||||||
def visit_command(self, name: str, info: Optional[QAPISourceInfo],
|
def visit_command(self, name: str, info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
arg_type: Optional[QAPISchemaObjectType],
|
arg_type: Optional[QAPISchemaObjectType],
|
||||||
ret_type: Optional[QAPISchemaType], gen: bool,
|
ret_type: Optional[QAPISchemaType], gen: bool,
|
||||||
|
@ -367,7 +366,8 @@ const QLitObject %(c_name)s = %(c_string)s;
|
||||||
self._gen_tree(name, 'command', obj, ifcond, features)
|
self._gen_tree(name, 'command', obj, ifcond, features)
|
||||||
|
|
||||||
def visit_event(self, name: str, info: Optional[QAPISourceInfo],
|
def visit_event(self, name: str, info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str], features: List[QAPISchemaFeature],
|
ifcond: QAPISchemaIfCond,
|
||||||
|
features: List[QAPISchemaFeature],
|
||||||
arg_type: Optional[QAPISchemaObjectType],
|
arg_type: Optional[QAPISchemaObjectType],
|
||||||
boxed: bool) -> None:
|
boxed: bool) -> None:
|
||||||
assert self._schema is not None
|
assert self._schema is not None
|
||||||
|
|
|
@ -25,6 +25,11 @@ from .expr import check_exprs
|
||||||
from .parser import QAPISchemaParser
|
from .parser import QAPISchemaParser
|
||||||
|
|
||||||
|
|
||||||
|
class QAPISchemaIfCond:
|
||||||
|
def __init__(self, ifcond=None):
|
||||||
|
self.ifcond = ifcond or []
|
||||||
|
|
||||||
|
|
||||||
class QAPISchemaEntity:
|
class QAPISchemaEntity:
|
||||||
meta: Optional[str] = None
|
meta: Optional[str] = None
|
||||||
|
|
||||||
|
@ -42,7 +47,7 @@ class QAPISchemaEntity:
|
||||||
# such place).
|
# such place).
|
||||||
self.info = info
|
self.info = info
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
self._ifcond = ifcond or []
|
self._ifcond = ifcond or QAPISchemaIfCond()
|
||||||
self.features = features or []
|
self.features = features or []
|
||||||
self._checked = False
|
self._checked = False
|
||||||
|
|
||||||
|
@ -593,7 +598,7 @@ class QAPISchemaVariants:
|
||||||
self.info,
|
self.info,
|
||||||
"discriminator member '%s' of %s must not be optional"
|
"discriminator member '%s' of %s must not be optional"
|
||||||
% (self._tag_name, base))
|
% (self._tag_name, base))
|
||||||
if self.tag_member.ifcond:
|
if self.tag_member.ifcond.ifcond:
|
||||||
raise QAPISemError(
|
raise QAPISemError(
|
||||||
self.info,
|
self.info,
|
||||||
"discriminator member '%s' of %s must not be conditional"
|
"discriminator member '%s' of %s must not be conditional"
|
||||||
|
@ -601,7 +606,7 @@ class QAPISchemaVariants:
|
||||||
else: # simple union
|
else: # simple union
|
||||||
assert isinstance(self.tag_member.type, QAPISchemaEnumType)
|
assert isinstance(self.tag_member.type, QAPISchemaEnumType)
|
||||||
assert not self.tag_member.optional
|
assert not self.tag_member.optional
|
||||||
assert self.tag_member.ifcond == []
|
assert self.tag_member.ifcond.ifcond == []
|
||||||
if self._tag_name: # flat union
|
if self._tag_name: # flat union
|
||||||
# branches that are not explicitly covered get an empty type
|
# branches that are not explicitly covered get an empty type
|
||||||
cases = {v.name for v in self.variants}
|
cases = {v.name for v in self.variants}
|
||||||
|
@ -646,7 +651,7 @@ class QAPISchemaMember:
|
||||||
assert isinstance(name, str)
|
assert isinstance(name, str)
|
||||||
self.name = name
|
self.name = name
|
||||||
self.info = info
|
self.info = info
|
||||||
self.ifcond = ifcond or []
|
self.ifcond = ifcond or QAPISchemaIfCond()
|
||||||
self.defined_in = None
|
self.defined_in = None
|
||||||
|
|
||||||
def set_defined_in(self, name):
|
def set_defined_in(self, name):
|
||||||
|
@ -968,11 +973,13 @@ class QAPISchema:
|
||||||
def _make_features(self, features, info):
|
def _make_features(self, features, info):
|
||||||
if features is None:
|
if features is None:
|
||||||
return []
|
return []
|
||||||
return [QAPISchemaFeature(f['name'], info, f.get('if'))
|
return [QAPISchemaFeature(f['name'], info,
|
||||||
|
QAPISchemaIfCond(f.get('if')))
|
||||||
for f in features]
|
for f in features]
|
||||||
|
|
||||||
def _make_enum_members(self, values, info):
|
def _make_enum_members(self, values, info):
|
||||||
return [QAPISchemaEnumMember(v['name'], info, v.get('if'))
|
return [QAPISchemaEnumMember(v['name'], info,
|
||||||
|
QAPISchemaIfCond(v.get('if')))
|
||||||
for v in values]
|
for v in values]
|
||||||
|
|
||||||
def _make_implicit_enum_type(self, name, info, ifcond, values):
|
def _make_implicit_enum_type(self, name, info, ifcond, values):
|
||||||
|
@ -1018,7 +1025,7 @@ class QAPISchema:
|
||||||
name = expr['enum']
|
name = expr['enum']
|
||||||
data = expr['data']
|
data = expr['data']
|
||||||
prefix = expr.get('prefix')
|
prefix = expr.get('prefix')
|
||||||
ifcond = expr.get('if')
|
ifcond = QAPISchemaIfCond(expr.get('if'))
|
||||||
features = self._make_features(expr.get('features'), info)
|
features = self._make_features(expr.get('features'), info)
|
||||||
self._def_entity(QAPISchemaEnumType(
|
self._def_entity(QAPISchemaEnumType(
|
||||||
name, info, doc, ifcond, features,
|
name, info, doc, ifcond, features,
|
||||||
|
@ -1036,7 +1043,8 @@ class QAPISchema:
|
||||||
self._make_features(features, info))
|
self._make_features(features, info))
|
||||||
|
|
||||||
def _make_members(self, data, info):
|
def _make_members(self, data, info):
|
||||||
return [self._make_member(key, value['type'], value.get('if'),
|
return [self._make_member(key, value['type'],
|
||||||
|
QAPISchemaIfCond(value.get('if')),
|
||||||
value.get('features'), info)
|
value.get('features'), info)
|
||||||
for (key, value) in data.items()]
|
for (key, value) in data.items()]
|
||||||
|
|
||||||
|
@ -1044,7 +1052,7 @@ class QAPISchema:
|
||||||
name = expr['struct']
|
name = expr['struct']
|
||||||
base = expr.get('base')
|
base = expr.get('base')
|
||||||
data = expr['data']
|
data = expr['data']
|
||||||
ifcond = expr.get('if')
|
ifcond = QAPISchemaIfCond(expr.get('if'))
|
||||||
features = self._make_features(expr.get('features'), info)
|
features = self._make_features(expr.get('features'), info)
|
||||||
self._def_entity(QAPISchemaObjectType(
|
self._def_entity(QAPISchemaObjectType(
|
||||||
name, info, doc, ifcond, features, base,
|
name, info, doc, ifcond, features, base,
|
||||||
|
@ -1067,7 +1075,7 @@ class QAPISchema:
|
||||||
name = expr['union']
|
name = expr['union']
|
||||||
data = expr['data']
|
data = expr['data']
|
||||||
base = expr.get('base')
|
base = expr.get('base')
|
||||||
ifcond = expr.get('if')
|
ifcond = QAPISchemaIfCond(expr.get('if'))
|
||||||
features = self._make_features(expr.get('features'), info)
|
features = self._make_features(expr.get('features'), info)
|
||||||
tag_name = expr.get('discriminator')
|
tag_name = expr.get('discriminator')
|
||||||
tag_member = None
|
tag_member = None
|
||||||
|
@ -1076,15 +1084,19 @@ class QAPISchema:
|
||||||
name, info, ifcond,
|
name, info, ifcond,
|
||||||
'base', self._make_members(base, info))
|
'base', self._make_members(base, info))
|
||||||
if tag_name:
|
if tag_name:
|
||||||
variants = [self._make_variant(key, value['type'],
|
variants = [
|
||||||
value.get('if'), info)
|
self._make_variant(key, value['type'],
|
||||||
for (key, value) in data.items()]
|
QAPISchemaIfCond(value.get('if')),
|
||||||
|
info)
|
||||||
|
for (key, value) in data.items()]
|
||||||
members = []
|
members = []
|
||||||
else:
|
else:
|
||||||
variants = [self._make_simple_variant(key, value['type'],
|
variants = [
|
||||||
value.get('if'), info)
|
self._make_simple_variant(key, value['type'],
|
||||||
for (key, value) in data.items()]
|
QAPISchemaIfCond(value.get('if')),
|
||||||
enum = [{'name': v.name, 'if': v.ifcond} for v in variants]
|
info)
|
||||||
|
for (key, value) in data.items()]
|
||||||
|
enum = [{'name': v.name, 'if': v.ifcond.ifcond} for v in variants]
|
||||||
typ = self._make_implicit_enum_type(name, info, ifcond, enum)
|
typ = self._make_implicit_enum_type(name, info, ifcond, enum)
|
||||||
tag_member = QAPISchemaObjectTypeMember('type', info, typ, False)
|
tag_member = QAPISchemaObjectTypeMember('type', info, typ, False)
|
||||||
members = [tag_member]
|
members = [tag_member]
|
||||||
|
@ -1097,11 +1109,13 @@ class QAPISchema:
|
||||||
def _def_alternate_type(self, expr, info, doc):
|
def _def_alternate_type(self, expr, info, doc):
|
||||||
name = expr['alternate']
|
name = expr['alternate']
|
||||||
data = expr['data']
|
data = expr['data']
|
||||||
ifcond = expr.get('if')
|
ifcond = QAPISchemaIfCond(expr.get('if'))
|
||||||
features = self._make_features(expr.get('features'), info)
|
features = self._make_features(expr.get('features'), info)
|
||||||
variants = [self._make_variant(key, value['type'], value.get('if'),
|
variants = [
|
||||||
info)
|
self._make_variant(key, value['type'],
|
||||||
for (key, value) in data.items()]
|
QAPISchemaIfCond(value.get('if')),
|
||||||
|
info)
|
||||||
|
for (key, value) in data.items()]
|
||||||
tag_member = QAPISchemaObjectTypeMember('type', info, 'QType', False)
|
tag_member = QAPISchemaObjectTypeMember('type', info, 'QType', False)
|
||||||
self._def_entity(
|
self._def_entity(
|
||||||
QAPISchemaAlternateType(name, info, doc, ifcond, features,
|
QAPISchemaAlternateType(name, info, doc, ifcond, features,
|
||||||
|
@ -1118,7 +1132,7 @@ class QAPISchema:
|
||||||
allow_oob = expr.get('allow-oob', False)
|
allow_oob = expr.get('allow-oob', False)
|
||||||
allow_preconfig = expr.get('allow-preconfig', False)
|
allow_preconfig = expr.get('allow-preconfig', False)
|
||||||
coroutine = expr.get('coroutine', False)
|
coroutine = expr.get('coroutine', False)
|
||||||
ifcond = expr.get('if')
|
ifcond = QAPISchemaIfCond(expr.get('if'))
|
||||||
features = self._make_features(expr.get('features'), info)
|
features = self._make_features(expr.get('features'), info)
|
||||||
if isinstance(data, OrderedDict):
|
if isinstance(data, OrderedDict):
|
||||||
data = self._make_implicit_object_type(
|
data = self._make_implicit_object_type(
|
||||||
|
@ -1137,7 +1151,7 @@ class QAPISchema:
|
||||||
name = expr['event']
|
name = expr['event']
|
||||||
data = expr.get('data')
|
data = expr.get('data')
|
||||||
boxed = expr.get('boxed', False)
|
boxed = expr.get('boxed', False)
|
||||||
ifcond = expr.get('if')
|
ifcond = QAPISchemaIfCond(expr.get('if'))
|
||||||
features = self._make_features(expr.get('features'), info)
|
features = self._make_features(expr.get('features'), info)
|
||||||
if isinstance(data, OrderedDict):
|
if isinstance(data, OrderedDict):
|
||||||
data = self._make_implicit_object_type(
|
data = self._make_implicit_object_type(
|
||||||
|
|
|
@ -13,7 +13,7 @@ This work is licensed under the terms of the GNU GPL, version 2.
|
||||||
# See the COPYING file in the top-level directory.
|
# See the COPYING file in the top-level directory.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import List, Optional, Sequence
|
from typing import List, Optional
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
c_enum_const,
|
c_enum_const,
|
||||||
|
@ -27,6 +27,7 @@ from .schema import (
|
||||||
QAPISchema,
|
QAPISchema,
|
||||||
QAPISchemaEnumMember,
|
QAPISchemaEnumMember,
|
||||||
QAPISchemaFeature,
|
QAPISchemaFeature,
|
||||||
|
QAPISchemaIfCond,
|
||||||
QAPISchemaObjectType,
|
QAPISchemaObjectType,
|
||||||
QAPISchemaObjectTypeMember,
|
QAPISchemaObjectTypeMember,
|
||||||
QAPISchemaType,
|
QAPISchemaType,
|
||||||
|
@ -50,13 +51,13 @@ const QEnumLookup %(c_name)s_lookup = {
|
||||||
''',
|
''',
|
||||||
c_name=c_name(name))
|
c_name=c_name(name))
|
||||||
for memb in members:
|
for memb in members:
|
||||||
ret += gen_if(memb.ifcond)
|
ret += gen_if(memb.ifcond.ifcond)
|
||||||
index = c_enum_const(name, memb.name, prefix)
|
index = c_enum_const(name, memb.name, prefix)
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
[%(index)s] = "%(name)s",
|
[%(index)s] = "%(name)s",
|
||||||
''',
|
''',
|
||||||
index=index, name=memb.name)
|
index=index, name=memb.name)
|
||||||
ret += gen_endif(memb.ifcond)
|
ret += gen_endif(memb.ifcond.ifcond)
|
||||||
|
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
},
|
},
|
||||||
|
@ -80,12 +81,12 @@ typedef enum %(c_name)s {
|
||||||
c_name=c_name(name))
|
c_name=c_name(name))
|
||||||
|
|
||||||
for memb in enum_members:
|
for memb in enum_members:
|
||||||
ret += gen_if(memb.ifcond)
|
ret += gen_if(memb.ifcond.ifcond)
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
%(c_enum)s,
|
%(c_enum)s,
|
||||||
''',
|
''',
|
||||||
c_enum=c_enum_const(name, memb.name, prefix))
|
c_enum=c_enum_const(name, memb.name, prefix))
|
||||||
ret += gen_endif(memb.ifcond)
|
ret += gen_endif(memb.ifcond.ifcond)
|
||||||
|
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
} %(c_name)s;
|
} %(c_name)s;
|
||||||
|
@ -125,7 +126,7 @@ struct %(c_name)s {
|
||||||
def gen_struct_members(members: List[QAPISchemaObjectTypeMember]) -> str:
|
def gen_struct_members(members: List[QAPISchemaObjectTypeMember]) -> str:
|
||||||
ret = ''
|
ret = ''
|
||||||
for memb in members:
|
for memb in members:
|
||||||
ret += gen_if(memb.ifcond)
|
ret += gen_if(memb.ifcond.ifcond)
|
||||||
if memb.optional:
|
if memb.optional:
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
bool has_%(c_name)s;
|
bool has_%(c_name)s;
|
||||||
|
@ -135,11 +136,11 @@ def gen_struct_members(members: List[QAPISchemaObjectTypeMember]) -> str:
|
||||||
%(c_type)s %(c_name)s;
|
%(c_type)s %(c_name)s;
|
||||||
''',
|
''',
|
||||||
c_type=memb.type.c_type(), c_name=c_name(memb.name))
|
c_type=memb.type.c_type(), c_name=c_name(memb.name))
|
||||||
ret += gen_endif(memb.ifcond)
|
ret += gen_endif(memb.ifcond.ifcond)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def gen_object(name: str, ifcond: Sequence[str],
|
def gen_object(name: str, ifcond: QAPISchemaIfCond,
|
||||||
base: Optional[QAPISchemaObjectType],
|
base: Optional[QAPISchemaObjectType],
|
||||||
members: List[QAPISchemaObjectTypeMember],
|
members: List[QAPISchemaObjectTypeMember],
|
||||||
variants: Optional[QAPISchemaVariants]) -> str:
|
variants: Optional[QAPISchemaVariants]) -> str:
|
||||||
|
@ -158,7 +159,7 @@ def gen_object(name: str, ifcond: Sequence[str],
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
|
|
||||||
''')
|
''')
|
||||||
ret += gen_if(ifcond)
|
ret += gen_if(ifcond.ifcond)
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
struct %(c_name)s {
|
struct %(c_name)s {
|
||||||
''',
|
''',
|
||||||
|
@ -192,7 +193,7 @@ struct %(c_name)s {
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
};
|
};
|
||||||
''')
|
''')
|
||||||
ret += gen_endif(ifcond)
|
ret += gen_endif(ifcond.ifcond)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -219,13 +220,13 @@ def gen_variants(variants: QAPISchemaVariants) -> str:
|
||||||
for var in variants.variants:
|
for var in variants.variants:
|
||||||
if var.type.name == 'q_empty':
|
if var.type.name == 'q_empty':
|
||||||
continue
|
continue
|
||||||
ret += gen_if(var.ifcond)
|
ret += gen_if(var.ifcond.ifcond)
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
%(c_type)s %(c_name)s;
|
%(c_type)s %(c_name)s;
|
||||||
''',
|
''',
|
||||||
c_type=var.type.c_unboxed_type(),
|
c_type=var.type.c_unboxed_type(),
|
||||||
c_name=c_name(var.name))
|
c_name=c_name(var.name))
|
||||||
ret += gen_endif(var.ifcond)
|
ret += gen_endif(var.ifcond.ifcond)
|
||||||
|
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
} u;
|
} u;
|
||||||
|
@ -307,7 +308,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
|
||||||
def visit_enum_type(self,
|
def visit_enum_type(self,
|
||||||
name: str,
|
name: str,
|
||||||
info: Optional[QAPISourceInfo],
|
info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
members: List[QAPISchemaEnumMember],
|
members: List[QAPISchemaEnumMember],
|
||||||
prefix: Optional[str]) -> None:
|
prefix: Optional[str]) -> None:
|
||||||
|
@ -318,7 +319,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
|
||||||
def visit_array_type(self,
|
def visit_array_type(self,
|
||||||
name: str,
|
name: str,
|
||||||
info: Optional[QAPISourceInfo],
|
info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
element_type: QAPISchemaType) -> None:
|
element_type: QAPISchemaType) -> None:
|
||||||
with ifcontext(ifcond, self._genh, self._genc):
|
with ifcontext(ifcond, self._genh, self._genc):
|
||||||
self._genh.preamble_add(gen_fwd_object_or_array(name))
|
self._genh.preamble_add(gen_fwd_object_or_array(name))
|
||||||
|
@ -328,7 +329,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
|
||||||
def visit_object_type(self,
|
def visit_object_type(self,
|
||||||
name: str,
|
name: str,
|
||||||
info: Optional[QAPISourceInfo],
|
info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
base: Optional[QAPISchemaObjectType],
|
base: Optional[QAPISchemaObjectType],
|
||||||
members: List[QAPISchemaObjectTypeMember],
|
members: List[QAPISchemaObjectTypeMember],
|
||||||
|
@ -351,7 +352,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor):
|
||||||
def visit_alternate_type(self,
|
def visit_alternate_type(self,
|
||||||
name: str,
|
name: str,
|
||||||
info: Optional[QAPISourceInfo],
|
info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
variants: QAPISchemaVariants) -> None:
|
variants: QAPISchemaVariants) -> None:
|
||||||
with ifcontext(ifcond, self._genh):
|
with ifcontext(ifcond, self._genh):
|
||||||
|
|
|
@ -13,7 +13,7 @@ This work is licensed under the terms of the GNU GPL, version 2.
|
||||||
See the COPYING file in the top-level directory.
|
See the COPYING file in the top-level directory.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import List, Optional, Sequence
|
from typing import List, Optional
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
c_enum_const,
|
c_enum_const,
|
||||||
|
@ -29,6 +29,7 @@ from .schema import (
|
||||||
QAPISchemaEnumMember,
|
QAPISchemaEnumMember,
|
||||||
QAPISchemaEnumType,
|
QAPISchemaEnumType,
|
||||||
QAPISchemaFeature,
|
QAPISchemaFeature,
|
||||||
|
QAPISchemaIfCond,
|
||||||
QAPISchemaObjectType,
|
QAPISchemaObjectType,
|
||||||
QAPISchemaObjectTypeMember,
|
QAPISchemaObjectTypeMember,
|
||||||
QAPISchemaType,
|
QAPISchemaType,
|
||||||
|
@ -78,7 +79,7 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
|
||||||
|
|
||||||
for memb in members:
|
for memb in members:
|
||||||
deprecated = 'deprecated' in [f.name for f in memb.features]
|
deprecated = 'deprecated' in [f.name for f in memb.features]
|
||||||
ret += gen_if(memb.ifcond)
|
ret += gen_if(memb.ifcond.ifcond)
|
||||||
if memb.optional:
|
if memb.optional:
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
if (visit_optional(v, "%(name)s", &obj->has_%(c_name)s)) {
|
if (visit_optional(v, "%(name)s", &obj->has_%(c_name)s)) {
|
||||||
|
@ -111,7 +112,7 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
ret += gen_endif(memb.ifcond)
|
ret += gen_endif(memb.ifcond.ifcond)
|
||||||
|
|
||||||
if variants:
|
if variants:
|
||||||
tag_member = variants.tag_member
|
tag_member = variants.tag_member
|
||||||
|
@ -125,7 +126,7 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
|
||||||
for var in variants.variants:
|
for var in variants.variants:
|
||||||
case_str = c_enum_const(tag_member.type.name, var.name,
|
case_str = c_enum_const(tag_member.type.name, var.name,
|
||||||
tag_member.type.prefix)
|
tag_member.type.prefix)
|
||||||
ret += gen_if(var.ifcond)
|
ret += gen_if(var.ifcond.ifcond)
|
||||||
if var.type.name == 'q_empty':
|
if var.type.name == 'q_empty':
|
||||||
# valid variant and nothing to do
|
# valid variant and nothing to do
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
|
@ -141,7 +142,7 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
|
||||||
case=case_str,
|
case=case_str,
|
||||||
c_type=var.type.c_name(), c_name=c_name(var.name))
|
c_type=var.type.c_name(), c_name=c_name(var.name))
|
||||||
|
|
||||||
ret += gen_endif(var.ifcond)
|
ret += gen_endif(var.ifcond.ifcond)
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
|
@ -227,7 +228,7 @@ bool visit_type_%(c_name)s(Visitor *v, const char *name,
|
||||||
c_name=c_name(name))
|
c_name=c_name(name))
|
||||||
|
|
||||||
for var in variants.variants:
|
for var in variants.variants:
|
||||||
ret += gen_if(var.ifcond)
|
ret += gen_if(var.ifcond.ifcond)
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
case %(case)s:
|
case %(case)s:
|
||||||
''',
|
''',
|
||||||
|
@ -253,7 +254,7 @@ bool visit_type_%(c_name)s(Visitor *v, const char *name,
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
break;
|
break;
|
||||||
''')
|
''')
|
||||||
ret += gen_endif(var.ifcond)
|
ret += gen_endif(var.ifcond.ifcond)
|
||||||
|
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
case QTYPE_NONE:
|
case QTYPE_NONE:
|
||||||
|
@ -352,7 +353,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
||||||
def visit_enum_type(self,
|
def visit_enum_type(self,
|
||||||
name: str,
|
name: str,
|
||||||
info: Optional[QAPISourceInfo],
|
info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
members: List[QAPISchemaEnumMember],
|
members: List[QAPISchemaEnumMember],
|
||||||
prefix: Optional[str]) -> None:
|
prefix: Optional[str]) -> None:
|
||||||
|
@ -363,7 +364,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
||||||
def visit_array_type(self,
|
def visit_array_type(self,
|
||||||
name: str,
|
name: str,
|
||||||
info: Optional[QAPISourceInfo],
|
info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
element_type: QAPISchemaType) -> None:
|
element_type: QAPISchemaType) -> None:
|
||||||
with ifcontext(ifcond, self._genh, self._genc):
|
with ifcontext(ifcond, self._genh, self._genc):
|
||||||
self._genh.add(gen_visit_decl(name))
|
self._genh.add(gen_visit_decl(name))
|
||||||
|
@ -372,7 +373,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
||||||
def visit_object_type(self,
|
def visit_object_type(self,
|
||||||
name: str,
|
name: str,
|
||||||
info: Optional[QAPISourceInfo],
|
info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
base: Optional[QAPISchemaObjectType],
|
base: Optional[QAPISchemaObjectType],
|
||||||
members: List[QAPISchemaObjectTypeMember],
|
members: List[QAPISchemaObjectTypeMember],
|
||||||
|
@ -394,7 +395,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
||||||
def visit_alternate_type(self,
|
def visit_alternate_type(self,
|
||||||
name: str,
|
name: str,
|
||||||
info: Optional[QAPISourceInfo],
|
info: Optional[QAPISourceInfo],
|
||||||
ifcond: Sequence[str],
|
ifcond: QAPISchemaIfCond,
|
||||||
features: List[QAPISchemaFeature],
|
features: List[QAPISchemaFeature],
|
||||||
variants: QAPISchemaVariants) -> None:
|
variants: QAPISchemaVariants) -> None:
|
||||||
with ifcontext(ifcond, self._genh, self._genc):
|
with ifcontext(ifcond, self._genh, self._genc):
|
||||||
|
|
|
@ -94,8 +94,8 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _print_if(ifcond, indent=4):
|
def _print_if(ifcond, indent=4):
|
||||||
if ifcond:
|
if ifcond.ifcond:
|
||||||
print('%sif %s' % (' ' * indent, ifcond))
|
print('%sif %s' % (' ' * indent, ifcond.ifcond))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _print_features(cls, features, indent=4):
|
def _print_features(cls, features, indent=4):
|
||||||
|
|
Loading…
Reference in New Issue