[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v8 01/22] qapi: Do not define enumeration value expl
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v8 01/22] qapi: Do not define enumeration value explicitly |
Date: |
Thu, 13 Dec 2018 16:37:03 +0400 |
The generated C enumeration types explicitly set the enumeration
constants to 0, 1, 2, ... That's exactly what you get when you don't
supply values.
Drop the explicit values. No change now, but it will avoid gaps in
the values when we later add support for 'if' conditions. Avoiding
such gaps will save us the trouble of changing the ENUM_lookup[]
tables to work without a sentinel.
We'll have to take care to ensure the headers required by the 'if'
conditions get always included before the generated QAPI code.
Fortunately, our convention to include "qemu/osdep.h" first in any .c
ensures that's the case for our CONFIG_FOO macros.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Markus Armbruster <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 046b7e5681..55c914ec44 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
- [Qemu-devel] [PATCH v8 00/22] qapi: add #if pre-processor conditions to generated code (part 2), Marc-André Lureau, 2018/12/13
- [Qemu-devel] [PATCH v8 01/22] qapi: Do not define enumeration value explicitly,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v8 02/22] qapi: change enum visitor and gen_enum* to take QAPISchemaMember, Marc-André Lureau, 2018/12/13
- [Qemu-devel] [PATCH v8 03/22] tests: print enum type members more like object type members, Marc-André Lureau, 2018/12/13
- [Qemu-devel] [PATCH v8 04/22] qapi: factor out checking for keys, Marc-André Lureau, 2018/12/13
- [Qemu-devel] [PATCH v8 05/22] qapi: improve reporting of unknown or missing keys, Marc-André Lureau, 2018/12/13
- [Qemu-devel] [PATCH v8 06/22] qapi: add a dictionary form with 'name' key for enum members, Marc-André Lureau, 2018/12/13
- [Qemu-devel] [PATCH v8 07/22] qapi: pass long form enum to make_enum_members, Marc-André Lureau, 2018/12/13