summaryrefslogtreecommitdiffstats
path: root/scripts/qapi.py
diff options
context:
space:
mode:
authorEric Blake2015-05-14 14:50:48 +0200
committerMarkus Armbruster2015-05-14 18:20:42 +0200
commit18df515ebbefa9f13474b128b8050d5fa346ea1e (patch)
tree98ab9f86e6ffadc62bf753da6090078f64184c4f /scripts/qapi.py
parentqapi: Fix C identifiers generated for names containing '.' (diff)
downloadqemu-18df515ebbefa9f13474b128b8050d5fa346ea1e.tar.gz
qemu-18df515ebbefa9f13474b128b8050d5fa346ea1e.tar.xz
qemu-18df515ebbefa9f13474b128b8050d5fa346ea1e.zip
qapi: Rename identical c_fun()/c_var() into c_name()
Now that the two functions are identical, we only need one of them, and we might as well give it a more descriptive name. Basically, the function serves as the translation from a QAPI name into a (portion of a) C identifier, without regards to whether it is a variable or function name. Signed-off-by: Eric Blake <eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts/qapi.py')
-rw-r--r--scripts/qapi.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 4b07805d72..a4701ca4ed 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -753,9 +753,9 @@ def camel_case(name):
new_name += ch.lower()
return new_name
-c_var_trans = string.maketrans('.-', '__')
+c_name_trans = string.maketrans('.-', '__')
-def c_var(name, protect=True):
+def c_name(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',
@@ -784,10 +784,7 @@ def c_var(name, protect=True):
polluted_words = set(['unix', 'errno'])
if protect and (name in c89_words | c99_words | c11_words | gcc_words | cpp_words | polluted_words):
return "q_" + name
- return name.translate(c_var_trans)
-
-def c_fun(name, protect=True):
- return c_var(name, protect)
+ return name.translate(c_name_trans)
def c_list_type(name):
return '%sList' % name
@@ -945,7 +942,7 @@ def guardend(name):
# ENUM_NAME -> ENUM_NAME, ENUM_NAME1 -> ENUM_NAME1, ENUM_Name2 -> ENUM_NAME2
# ENUM24_Name -> ENUM24_NAME
def _generate_enum_string(value):
- c_fun_str = c_fun(value, False)
+ c_fun_str = c_name(value, False)
if value.isupper():
return c_fun_str