aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi/schema.py
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2021-10-25 06:24:02 +0200
committerMarkus Armbruster <armbru@redhat.com>2021-10-27 17:18:55 +0200
commitb6c18755e41f7b40aad4c2c8188fb1719535699d (patch)
tree461b80ebb2bd36703020099c09172d5c1fb544bf /scripts/qapi/schema.py
parent75ecee7262548d21a9e20c12f0b3b12f8a51d5c6 (diff)
downloadqemu-b6c18755e41f7b40aad4c2c8188fb1719535699d.zip
qemu-b6c18755e41f7b40aad4c2c8188fb1719535699d.tar.gz
qemu-b6c18755e41f7b40aad4c2c8188fb1719535699d.tar.bz2
qapi: Add feature flags to enum members
This is quite similar to commit 84ab008687 "qapi: Add feature flags to struct members", only for enums instead of structs. Special feature flag 'deprecated' is silently ignored there. This is okay only because it will be implemented shortly. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20211025042405.3762351-3-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'scripts/qapi/schema.py')
-rw-r--r--scripts/qapi/schema.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 004d709..6d5f465 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -708,6 +708,19 @@ class QAPISchemaMember:
class QAPISchemaEnumMember(QAPISchemaMember):
role = 'value'
+ def __init__(self, name, info, ifcond=None, features=None):
+ super().__init__(name, info, ifcond)
+ for f in features or []:
+ assert isinstance(f, QAPISchemaFeature)
+ f.set_defined_in(name)
+ self.features = features or []
+
+ def connect_doc(self, doc):
+ super().connect_doc(doc)
+ if doc:
+ for f in self.features:
+ doc.connect_feature(f)
+
class QAPISchemaFeature(QAPISchemaMember):
role = 'feature'
@@ -980,9 +993,14 @@ class QAPISchema:
QAPISchemaIfCond(f.get('if')))
for f in features]
+ def _make_enum_member(self, name, ifcond, features, info):
+ return QAPISchemaEnumMember(name, info,
+ QAPISchemaIfCond(ifcond),
+ self._make_features(features, info))
+
def _make_enum_members(self, values, info):
- return [QAPISchemaEnumMember(v['name'], info,
- QAPISchemaIfCond(v.get('if')))
+ return [self._make_enum_member(v['name'], v.get('if'),
+ v.get('features'), info)
for v in values]
def _make_array_type(self, element_type, info):