[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/15] qapi: do not protect enum values from namespac
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 04/15] qapi: do not protect enum values from namespace pollution |
Date: |
Thu, 27 Sep 2012 10:28:18 -0300 |
From: Paolo Bonzini <address@hidden>
Enum values are always preceded by the uppercase name of the enum, so
they do not conflict with reserved words.
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
scripts/qapi-types.py | 4 ++--
scripts/qapi-visit.py | 2 +-
scripts/qapi.py | 8 ++++----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 49ef569..1b84834 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -91,9 +91,9 @@ const char *%(name)s_lookup[] = {
def generate_enum_name(name):
if name.isupper():
- return c_fun(name)
+ return c_fun(name, False)
new_name = ''
- for c in c_fun(name):
+ for c in c_fun(name, False):
if c.isupper():
new_name += '_'
new_name += c
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index e2093e8..a360de7 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -173,7 +173,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const
char *name, Error **
break;
''',
abbrev = de_camel_case(name).upper(),
- enum = c_fun(de_camel_case(key)).upper(),
+ enum = c_fun(de_camel_case(key),False).upper(),
c_type=members[key],
c_name=c_fun(key))
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 122b4cb..057332e 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -141,7 +141,7 @@ def camel_case(name):
new_name += ch.lower()
return new_name
-def c_var(name):
+def c_var(name, protect=True):
# ANSI X3J11/88-090, 3.1.1
c89_words = set(['auto', 'break', 'case', 'char', 'const', 'continue',
'default', 'do', 'double', 'else', 'enum', 'extern',
'float',
@@ -156,12 +156,12 @@ def c_var(name):
# GCC http://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/C-Extensions.html
# excluding _.*
gcc_words = set(['asm', 'typeof'])
- if name in c89_words | c99_words | c11_words | gcc_words:
+ if protect and (name in c89_words | c99_words | c11_words | gcc_words):
return "q_" + name
return name.replace('-', '_').lstrip("*")
-def c_fun(name):
- return c_var(name).replace('.', '_')
+def c_fun(name, protect=True):
+ return c_var(name, protect).replace('.', '_')
def c_list_type(name):
return '%sList' % name
--
1.7.12.315.g682ce8b
- [Qemu-devel] [PULL 00/15]: QMP queue, Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 03/15] Add qemu-ga-client script, Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 06/15] pci-assign: use monitor_handle_fd_param, Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 05/15] qapi: add "unix" to the set of reserved words, Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 01/15] Make negotiation optional in QEMUMonitorProtocol, Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 04/15] qapi: do not protect enum values from namespace pollution,
Luiz Capitulino <=
- [Qemu-devel] [PULL 02/15] Support settimeout in QEMUMonitorProtocol, Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 08/15] qapi: convert add_client, Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 07/15] monitor: add Error * argument to monitor_get_fd, Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 11/15] hmp: dump-guest-memory: hardcode protocol argument to "file:", Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 09/15] qmp: dump-guest-memory: improve schema doc (again), Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 13/15] qmp: qmp_send_key(): accept key codes in hex, Luiz Capitulino, 2012/09/27