diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2021-08-04 12:31:02 +0400 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-08-26 13:53:56 +0200 |
commit | 3ad64edfad2fa404e866c01f6d427ed4fe4f4f0f (patch) | |
tree | 0dfacc884ce4a8aeb40e5a0e9ed57586b0a982e8 /scripts | |
parent | 5d83b9a130690f879d5f33e991beabe69cb88bc8 (diff) |
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>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qapi/common.py | 4 | ||||
-rw-r--r-- | scripts/qapi/expr.py | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 3d7272a702..63a2e502fb 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -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) + ')' diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index d7a34655a7..f3ce10fb3e 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -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: |