From 18df515ebbefa9f13474b128b8050d5fa346ea1e Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 14 May 2015 06:50:48 -0600 Subject: 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 Signed-off-by: Markus Armbruster --- scripts/qapi.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'scripts/qapi.py') 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 @@ 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 -- cgit v1.1