mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
qapi: make 'if' condition strings simple identifiers
Change the 'if' condition strings to be C-agnostic. It will accept '[A-Z][A-Z0-9_]*' identifiers. This allows to express configuration conditions in other languages (Rust or Python for ex) or other more suitable forms. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Tested-by: John Snow <jsnow@redhat.com> Message-Id: <20210804083105.97531-11-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Rebased with semantic conflict in redefined-event.json] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
2b7d214536
commit
8a9f1e1d9c
25 changed files with 206 additions and 208 deletions
|
@ -275,10 +275,10 @@ def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None:
|
|||
|
||||
def _check_if(cond: Union[str, object]) -> None:
|
||||
if isinstance(cond, str):
|
||||
if not cond.strip():
|
||||
if not re.match(r'^[A-Z][A-Z0-9_]*$', cond):
|
||||
raise QAPISemError(
|
||||
info,
|
||||
"'if' condition '%s' of %s makes no sense"
|
||||
"'if' condition '%s' of %s is not a valid identifier"
|
||||
% (cond, source))
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue