diff options
author | Luiz Capitulino <lcapitulino@redhat.com> | 2012-07-27 15:44:25 -0300 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2012-08-13 13:21:02 -0300 |
commit | f01f594b63becfc17cb23b4c15193230d01592e4 (patch) | |
tree | 1321ce7cf6b311eb1c141e304ac39c3acc4cb4fa /scripts | |
parent | b68a8472c17d2d2127afcf1a8dc57884e6584173 (diff) |
qapi: generate correct enum names for camel case enums
An enum like GenericError in the schema, should generate
GENERIC_ERROR and not GENERICERROR.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qapi-types.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 3ed9f0489..9b7da96ef 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -79,6 +79,16 @@ const char *%(name)s_lookup[] = { ''') return ret +def generate_enum_name(name): + if name.isupper(): + return c_fun(name) + new_name = '' + for c in c_fun(name): + 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[]; @@ -100,7 +110,7 @@ typedef enum %(name)s %(abbrev)s_%(value)s = %(i)d, ''', abbrev=de_camel_case(name).upper(), - value=c_fun(value).upper(), + value=generate_enum_name(value), i=i) i += 1 |