diff options
author | Markus Armbruster <armbru@redhat.com> | 2021-10-25 06:24:04 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-10-27 17:19:34 +0200 |
commit | aa2370444b62f8f9a809c024d0c41cb40658a5c3 (patch) | |
tree | 7b55c4687b9ba2f2c426b106772c14e82761db5a /scripts | |
parent | ed29bb28f8b0b17e965efcc2535fc32e101e3ceb (diff) | |
download | qemu-aa2370444b62f8f9a809c024d0c41cb40658a5c3.zip qemu-aa2370444b62f8f9a809c024d0c41cb40658a5c3.tar.gz qemu-aa2370444b62f8f9a809c024d0c41cb40658a5c3.tar.bz2 |
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')
-rw-r--r-- | scripts/qapi/types.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 831294f..ab2441a 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 |