[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-4.0 v7 02/27] qapi: do not define enumeration va
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH for-4.0 v7 02/27] qapi: do not define enumeration value explicitly |
Date: |
Sat, 8 Dec 2018 15:15:41 +0400 |
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.
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 7b62a4c7b0..7ea0cf5139 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.20.0.rc1
[Qemu-devel] [PATCH for-4.0 v7 02/27] qapi: do not define enumeration value explicitly,
Marc-André Lureau <=
[Qemu-devel] [PATCH for-4.0 v7 03/27] qapi: rename QAPISchemaEnumType.values to .members, Marc-André Lureau, 2018/12/08
[Qemu-devel] [PATCH for-4.0 v7 04/27] qapi: change enum visitor and gen_enum* to take QAPISchemaMember, Marc-André Lureau, 2018/12/08
[Qemu-devel] [PATCH for-4.0 v7 05/27] tests: print enum type members more like object type members, Marc-André Lureau, 2018/12/08
[Qemu-devel] [PATCH for-4.0 v7 06/27] qapi: factor out checking for keys, Marc-André Lureau, 2018/12/08
[Qemu-devel] [PATCH for-4.0 v7 08/27] qapi: add a dictionary form with 'name' key for enum members, Marc-André Lureau, 2018/12/08