mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-08 05:34:59 +00:00
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>
This commit is contained in:
parent
b68a8472c1
commit
f01f594b63
@ -79,6 +79,16 @@ const char *%(name)s_lookup[] = {
|
|||||||
''')
|
''')
|
||||||
return ret
|
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):
|
def generate_enum(name, values):
|
||||||
lookup_decl = mcgen('''
|
lookup_decl = mcgen('''
|
||||||
extern const char *%(name)s_lookup[];
|
extern const char *%(name)s_lookup[];
|
||||||
@ -100,7 +110,7 @@ typedef enum %(name)s
|
|||||||
%(abbrev)s_%(value)s = %(i)d,
|
%(abbrev)s_%(value)s = %(i)d,
|
||||||
''',
|
''',
|
||||||
abbrev=de_camel_case(name).upper(),
|
abbrev=de_camel_case(name).upper(),
|
||||||
value=c_fun(value).upper(),
|
value=generate_enum_name(value),
|
||||||
i=i)
|
i=i)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user