mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
qapi: add 'any' condition
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20210804083105.97531-8-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
5d83b9a130
commit
3ad64edfad
11 changed files with 27 additions and 12 deletions
|
@ -207,7 +207,7 @@ def cgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> str:
|
|||
return ifcond
|
||||
|
||||
oper, operands = next(iter(ifcond.items()))
|
||||
oper = {'all': '&&'}[oper]
|
||||
oper = {'all': '&&', 'any': '||'}[oper]
|
||||
operands = [cgen_ifcond(o) for o in operands]
|
||||
return '(' + (') ' + oper + ' (').join(operands) + ')'
|
||||
|
||||
|
@ -220,7 +220,7 @@ def docgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> str:
|
|||
return ifcond
|
||||
|
||||
oper, operands = next(iter(ifcond.items()))
|
||||
oper = {'all': ' and '}[oper]
|
||||
oper = {'all': ' and ', 'any': ' or '}[oper]
|
||||
operands = [docgen_ifcond(o) for o in operands]
|
||||
return '(' + oper.join(operands) + ')'
|
||||
|
||||
|
|
|
@ -290,16 +290,16 @@ def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None:
|
|||
raise QAPISemError(
|
||||
info,
|
||||
"'if' condition dict of %s must have one key: "
|
||||
"'all'" % source)
|
||||
"'all' or 'any'" % source)
|
||||
check_keys(cond, info, "'if' condition", [],
|
||||
["all"])
|
||||
["all", "any"])
|
||||
|
||||
oper, operands = next(iter(cond.items()))
|
||||
if not operands:
|
||||
raise QAPISemError(
|
||||
info, "'if' condition [] of %s is useless" % source)
|
||||
|
||||
if oper in ("all") and not isinstance(operands, list):
|
||||
if oper in ("all", "any") and not isinstance(operands, list):
|
||||
raise QAPISemError(
|
||||
info, "'%s' condition of %s must be an array" % (oper, source))
|
||||
for operand in operands:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue