aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi.py
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-09-19 16:31:06 +0200
committerLuiz Capitulino <lcapitulino@redhat.com>2012-09-26 10:45:02 -0300
commiteda50a656f52a5172fa8a95f7b217565b90d413e (patch)
tree2a057d7c6a8525f04c9b86984ca18c407010f1e1 /scripts/qapi.py
parentf513cbf7503d8db3778df436beaf25f3d8260317 (diff)
qapi: do not protect enum values from namespace pollution
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 <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'scripts/qapi.py')
-rw-r--r--scripts/qapi.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 122b4cb6d1..057332e4ca 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