mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
qapi: add 'not' condition operation
For the sake of completeness, introduce the 'not' condition. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20210804083105.97531-10-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Long line broken in tests/qapi-schema/qapi-schema-test.json] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
8a156d89d1
commit
2b7d214536
10 changed files with 25 additions and 9 deletions
|
@ -207,6 +207,8 @@ def cgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> str:
|
|||
return ifcond
|
||||
|
||||
oper, operands = next(iter(ifcond.items()))
|
||||
if oper == 'not':
|
||||
return '!' + cgen_ifcond(operands)
|
||||
oper = {'all': '&&', 'any': '||'}[oper]
|
||||
operands = [cgen_ifcond(o) for o in operands]
|
||||
return '(' + (') ' + oper + ' (').join(operands) + ')'
|
||||
|
@ -220,6 +222,8 @@ def docgen_ifcond(ifcond: Union[str, Dict[str, Any]]) -> str:
|
|||
return ifcond
|
||||
|
||||
oper, operands = next(iter(ifcond.items()))
|
||||
if oper == 'not':
|
||||
return '!' + docgen_ifcond(operands)
|
||||
oper = {'all': ' and ', 'any': ' or '}[oper]
|
||||
operands = [docgen_ifcond(o) for o in operands]
|
||||
return '(' + oper.join(operands) + ')'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue