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) + ')'
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) + ')'
raise QAPISemError(
info,
"'if' condition dict of %s must have one key: "
- "'all' or 'any'" % source)
+ "'all', 'any' or 'not'" % source)
check_keys(cond, info, "'if' condition", [],
- ["all", "any"])
+ ["all", "any", "not"])
oper, operands = next(iter(cond.items()))
if not operands:
raise QAPISemError(
info, "'if' condition [] of %s is useless" % source)
+ if oper == "not":
+ _check_if(operands)
+ return
if oper in ("all", "any") and not isinstance(operands, list):
raise QAPISemError(
info, "'%s' condition of %s must be an array" % (oper, source))
bad-if-key.json: In struct 'TestIfStruct':
bad-if-key.json:2: 'if' condition has unknown key 'value'
-Valid keys are 'all', 'any'.
+Valid keys are 'all', 'any', 'not'.
bad-if-keys.json: In struct 'TestIfStruct':
-bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all' or 'any'
+bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all', 'any' or 'not'
##
{ 'alternate': 'Alternate',
'features': [ 'alt-feat' ],
- 'data': { 'i': 'int', 'b': 'bool' } }
+ 'data': { 'i': 'int', 'b': 'bool' },
+ 'if': { 'not': 'IFNOT' } }
##
# == Another subsection
tag type
case i: int
case b: bool
+ if OrderedDict([('not', 'IFNOT')])
feature alt-feat
object q_obj_cmd-arg
member arg1: int optional=False
a feature
+If
+~~
+
+"!IFNOT"
+
+
Another subsection
==================
enum-if-invalid.json: In enum 'TestIfEnum':
enum-if-invalid.json:2: 'if' condition has unknown key 'val'
-Valid keys are 'all', 'any'.
+Valid keys are 'all', 'any', 'not'.
{ 'command': 'test-if-alternate-cmd',
'data': { 'alt-cmd-arg': 'TestIfAlternate' },
- 'if': { 'all': ['defined(TEST_IF_ALT)'] } }
+ 'if': { 'all': ['defined(TEST_IF_ALT)',
+ {'not': 'defined(TEST_IF_NOT_ALT)'}] } }
{ 'command': 'test-if-cmd',
'data': {
if OrderedDict([('all', ['defined(TEST_IF_ALT)', 'defined(TEST_IF_STRUCT)'])])
object q_obj_test-if-alternate-cmd-arg
member alt-cmd-arg: TestIfAlternate optional=False
- if OrderedDict([('all', ['defined(TEST_IF_ALT)'])])
+ if OrderedDict([('all', ['defined(TEST_IF_ALT)', OrderedDict([('not', 'defined(TEST_IF_NOT_ALT)')])])])
command test-if-alternate-cmd q_obj_test-if-alternate-cmd-arg -> None
gen=True success_response=True boxed=False oob=False preconfig=False
- if OrderedDict([('all', ['defined(TEST_IF_ALT)'])])
+ if OrderedDict([('all', ['defined(TEST_IF_ALT)', OrderedDict([('not', 'defined(TEST_IF_NOT_ALT)')])])])
object q_obj_test-if-cmd-arg
member foo: TestIfStruct optional=False
member bar: TestIfEnum optional=False