[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/11] qapi script: code move for generate_enum_name(
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 05/11] qapi script: code move for generate_enum_name() |
Date: |
Tue, 11 Mar 2014 09:41:05 -0400 |
From: Wenchao Xia <address@hidden>
Later both qapi-types.py and qapi-visit.py need a common function
for enum name generation.
Signed-off-by: Wenchao Xia <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
scripts/qapi-types.py | 10 ----------
scripts/qapi.py | 10 ++++++++++
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 2c6e0dc..35ad993 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -127,16 +127,6 @@ const char *%(name)s_lookup[] = {
''')
return ret
-def generate_enum_name(name):
- if name.isupper():
- return c_fun(name, False)
- new_name = ''
- for c in c_fun(name, False):
- if c.isupper():
- new_name += '_'
- new_name += c
- return new_name.lstrip('_').upper()
-
def generate_enum(name, values):
lookup_decl = mcgen('''
extern const char *%(name)s_lookup[];
diff --git a/scripts/qapi.py b/scripts/qapi.py
index f1ca5b6..0de9fe2 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -467,3 +467,13 @@ def guardend(name):
''',
name=guardname(name))
+
+def generate_enum_name(name):
+ if name.isupper():
+ return c_fun(name, False)
+ new_name = ''
+ for c in c_fun(name, False):
+ if c.isupper():
+ new_name += '_'
+ new_name += c
+ return new_name.lstrip('_').upper()
--
1.8.1.4
- [Qemu-devel] [PULL for-2.0 00/11] QMP queue, Luiz Capitulino, 2014/03/11
- [Qemu-devel] [PULL 06/11] qapi script: use same function to generate enum string, Luiz Capitulino, 2014/03/11
- [Qemu-devel] [PULL 05/11] qapi script: code move for generate_enum_name(),
Luiz Capitulino <=
- [Qemu-devel] [PULL 01/11] qapi script: remember explicitly defined enum values, Luiz Capitulino, 2014/03/11
- [Qemu-devel] [PULL 02/11] qapi script: add check for duplicated key, Luiz Capitulino, 2014/03/11
- [Qemu-devel] [PULL 03/11] qapi script: remember line number in schema parsing, Luiz Capitulino, 2014/03/11
- [Qemu-devel] [PULL 08/11] qapi: convert BlockdevOptions to use enum discriminator, Luiz Capitulino, 2014/03/11
- [Qemu-devel] [PULL 10/11] qapi script: do not add "_" for every capitalized char in enum, Luiz Capitulino, 2014/03/11
- [Qemu-devel] [PULL 11/11] tests: test-qmp-commands: Fix double free, Luiz Capitulino, 2014/03/11
- [Qemu-devel] [PULL 07/11] qapi script: support enum type as discriminator in union, Luiz Capitulino, 2014/03/11
- [Qemu-devel] [PULL 04/11] qapi script: check correctness of union, Luiz Capitulino, 2014/03/11
- [Qemu-devel] [PULL 09/11] qapi script: do not allow string discriminator, Luiz Capitulino, 2014/03/11
- Re: [Qemu-devel] [PULL for-2.0 00/11] QMP queue, Peter Maydell, 2014/03/12