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>
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 4b07805..a4701ca 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -753,9 +753,9 @@
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 @@
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 @@
# 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