diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2021-08-04 12:30:59 +0400 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-08-26 13:53:56 +0200 |
commit | 6cc2e4817ff5b33d6f67e0a5f27dbd1112d1ecd5 (patch) | |
tree | d4f859ddbaf3045f943209012215a388096c3a94 /scripts/qapi/schema.py | |
parent | 33aa3267bacc5a7af363c0ffa5f1bdabba54b989 (diff) |
qapi: introduce QAPISchemaIfCond.cgen()
Instead of building prepocessor conditions from a list of string, use
the result generated from QAPISchemaIfCond.cgen() and hide the
implementation details.
Note: this patch introduces a minor regression, generating a redundant
pair of parenthesis. This is mostly fixed in a later patch in this
series ("qapi: replace if condition list with dict [..]")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210804083105.97531-5-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts/qapi/schema.py')
-rw-r--r-- | scripts/qapi/schema.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 86fcd6cbd5..4ea7e88846 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -19,7 +19,7 @@ import os import re from typing import Optional -from .common import POINTER_SUFFIX, c_name +from .common import POINTER_SUFFIX, c_name, cgen_ifcond from .error import QAPIError, QAPISemError, QAPISourceError from .expr import check_exprs from .parser import QAPISchemaParser @@ -29,6 +29,9 @@ class QAPISchemaIfCond: def __init__(self, ifcond=None): self.ifcond = ifcond or [] + def cgen(self): + return cgen_ifcond(self.ifcond) + def is_present(self): return bool(self.ifcond) |