[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 06/27] qapi: do not define enumeration value expl
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v6 06/27] qapi: do not define enumeration value explicitly |
Date: |
Fri, 6 Jul 2018 12:57:32 +0200 |
The C standard has the initial value at 0 and the subsequent values
incremented by 1. No need to set this explicitely.
This will prevent from artificial "gaps" when compiling out some enum
values and having unnecessarily large MAX values & enums arrays, or
simplifying iterating over valid enum values.
Whenever config-host.h is changed, all the enum/types are recompiled.
(a subsequent patch will split the schema. Target-specific poisoined
conditionals will be added. They cannot be mixed with the common
schema: it is not possible to end up with enums of different values in
common and target builds)
Signed-off-by: Marc-André Lureau <address@hidden>
---
scripts/qapi/common.py | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 02c5c6767a..6f9498566e 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -2045,14 +2045,11 @@ typedef enum %(c_name)s {
''',
c_name=c_name(name))
- i = 0
for value in enum_values:
ret += mcgen('''
- %(c_enum)s = %(i)d,
+ %(c_enum)s,
''',
- c_enum=c_enum_const(name, value, prefix),
- i=i)
- i += 1
+ c_enum=c_enum_const(name, value, prefix))
ret += mcgen('''
} %(c_name)s;
--
2.18.0.rc1
- [Qemu-devel] [PATCH v6 00/27] qapi: add #if pre-processor conditions to generated code (part 2), Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 01/27] qmp-shell: learn to send commands with quoted arguments, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 03/27] tests: change /0.15/* tests to /qmp/*, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 02/27] json: remove useless return value from lexer/parser, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 04/27] qapi: Fix some pycodestyle-3 complaints, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 06/27] qapi: do not define enumeration value explicitly,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v6 07/27] qapi: rename QAPISchemaEnumType.values to .members, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 05/27] qapi: include osdep.h in type headers, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 08/27] qapi: change enum visitor and gen_enum* to take QAPISchemaMember, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 10/27] qapi: factor out checking for keys, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 09/27] tests: print enum type members more like object type members, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 11/27] qapi: improve reporting of unknown or missing keys, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 12/27] qapi: add a dictionnary form with 'name' key for enum members, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 14/27] qapi-event: add 'if' condition to implicit event enum, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 13/27] qapi: add 'if' to enum members, Marc-André Lureau, 2018/07/06
- [Qemu-devel] [PATCH v6 15/27] qapi: rename allow_dict to allow_implicit, Marc-André Lureau, 2018/07/06