summaryrefslogtreecommitdiffstats
path: root/scripts/qapi
diff options
context:
space:
mode:
authorMarkus Armbruster2021-10-25 06:24:04 +0200
committerMarkus Armbruster2021-10-27 17:19:34 +0200
commitaa2370444b62f8f9a809c024d0c41cb40658a5c3 (patch)
tree7b55c4687b9ba2f2c426b106772c14e82761db5a /scripts/qapi
parentqapi: Move compat policy from QObject to generic visitor (diff)
downloadqemu-aa2370444b62f8f9a809c024d0c41cb40658a5c3.tar.gz
qemu-aa2370444b62f8f9a809c024d0c41cb40658a5c3.tar.xz
qemu-aa2370444b62f8f9a809c024d0c41cb40658a5c3.zip
qapi: Implement deprecated-input={reject,crash} for enum values
This copies the code implementing the policy from qapi/qmp-dispatch.c to qapi/qobject-input-visitor.c. Tolerable, but if we acquire more copies, we should look into factoring them out. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Peter Krempa <pkrempa@redhat.com> Acked-by: Peter Krempa <pkrempa@redhat.com> Message-Id: <20211025042405.3762351-5-armbru@redhat.com>
Diffstat (limited to 'scripts/qapi')
-rw-r--r--scripts/qapi/types.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py
index 831294fe42..ab2441adc9 100644
--- a/scripts/qapi/types.py
+++ b/scripts/qapi/types.py
@@ -38,6 +38,8 @@ objects_seen = set()
def gen_enum_lookup(name: str,
members: List[QAPISchemaEnumMember],
prefix: Optional[str] = None) -> str:
+ max_index = c_enum_const(name, '_MAX', prefix)
+ flags = ''
ret = mcgen('''
const QEnumLookup %(c_name)s_lookup = {
@@ -52,13 +54,26 @@ const QEnumLookup %(c_name)s_lookup = {
''',
index=index, name=memb.name)
ret += memb.ifcond.gen_endif()
+ if 'deprecated' in (f.name for f in memb.features):
+ flags += mcgen('''
+ [%(index)s] = QAPI_ENUM_DEPRECATED,
+''',
+ index=index)
+
+ if flags:
+ ret += mcgen('''
+ },
+ .flags = (const unsigned char[%(max_index)s]) {
+''',
+ max_index=max_index)
+ ret += flags
ret += mcgen('''
},
.size = %(max_index)s
};
''',
- max_index=c_enum_const(name, '_MAX', prefix))
+ max_index=max_index)
return ret