From 6299659f54420955419c4995283f7dd770367939 Mon Sep 17 00:00:00 2001 From: Wenchao Xia Date: Tue, 4 Mar 2014 18:44:35 -0800 Subject: [PATCH] qapi script: code move for generate_enum_name() Later both qapi-types.py and qapi-visit.py need a common function for enum name generation. Signed-off-by: Wenchao Xia Reviewed-by: Eric Blake Reviewed-by: Markus Armbruster Signed-off-by: Luiz Capitulino --- scripts/qapi-types.py | 10 ---------- scripts/qapi.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 2c6e0dcd5c..35ad9931b6 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -127,16 +127,6 @@ const char *%(name)s_lookup[] = { ''') return ret -def generate_enum_name(name): - if name.isupper(): - return c_fun(name, False) - new_name = '' - for c in c_fun(name, False): - if c.isupper(): - new_name += '_' - new_name += c - return new_name.lstrip('_').upper() - def generate_enum(name, values): lookup_decl = mcgen(''' extern const char *%(name)s_lookup[]; diff --git a/scripts/qapi.py b/scripts/qapi.py index f1ca5b6d1c..0de9fe2cc5 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -467,3 +467,13 @@ def guardend(name): ''', name=guardname(name)) + +def generate_enum_name(name): + if name.isupper(): + return c_fun(name, False) + new_name = '' + for c in c_fun(name, False): + if c.isupper(): + new_name += '_' + new_name += c + return new_name.lstrip('_').upper()