summaryrefslogtreecommitdiffstats
path: root/scripts/qapi/gen.py
diff options
context:
space:
mode:
authorPeter Maydell2021-08-26 14:42:34 +0200
committerPeter Maydell2021-08-26 14:42:34 +0200
commitc83fcfaf8a54d0d034bd0edf7bbb3b0d16669be9 (patch)
treec25238aa2e85e53975e34765616fb0a3976bf2f0 /scripts/qapi/gen.py
parentMerge remote-tracking branch 'remotes/ehabkost-gl/tags/x86-next-pull-request'... (diff)
parentqapi: make 'if' condition strings simple identifiers (diff)
downloadqemu-c83fcfaf8a54d0d034bd0edf7bbb3b0d16669be9.tar.gz
qemu-c83fcfaf8a54d0d034bd0edf7bbb3b0d16669be9.tar.xz
qemu-c83fcfaf8a54d0d034bd0edf7bbb3b0d16669be9.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-08-26' into staging
QAPI patches patches for 2021-08-26 # gpg: Signature made Thu 26 Aug 2021 13:18:34 BST # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2021-08-26: qapi: make 'if' condition strings simple identifiers qapi: add 'not' condition operation qapi: Use 'if': { 'any': ... } where appropriate qapi: add 'any' condition qapi: replace if condition list with dict {'all': [...]} qapidoc: introduce QAPISchemaIfCond.docgen() qapi: introduce QAPISchemaIfCond.cgen() qapi: add QAPISchemaIfCond.is_present() qapi: wrap Sequence[str] in an object docs: update the documentation upfront about schema configuration qapi: Fix crash on redefinition with a different condition Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi/gen.py')
-rw-r--r--scripts/qapi/gen.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
index 1fa503bdbd..51a597a025 100644
--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -18,7 +18,6 @@ from typing import (
Dict,
Iterator,
Optional,
- Sequence,
Tuple,
)
@@ -32,6 +31,7 @@ from .common import (
mcgen,
)
from .schema import (
+ QAPISchemaIfCond,
QAPISchemaModule,
QAPISchemaObjectType,
QAPISchemaVisitor,
@@ -85,7 +85,7 @@ class QAPIGen:
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:
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':
out += '\n'
added = added[1:]
- out += gen_if(ifcond)
+ out += gen_if(ifcond.cgen())
out += added
- out += gen_endif(ifcond)
+ out += gen_endif(ifcond.cgen())
return out
@@ -127,9 +127,9 @@ def build_params(arg_type: Optional[QAPISchemaObjectType],
class QAPIGenCCode(QAPIGen):
def __init__(self, fname: str):
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
self._start_if = (ifcond, self._body, self._preamble)
@@ -187,7 +187,7 @@ class QAPIGenH(QAPIGenC):
@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()`.