mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
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 <wenchaoqemu@gmail.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
b86b05ed60
commit
6299659f54
2 changed files with 10 additions and 10 deletions
|
@ -127,16 +127,6 @@ const char *%(name)s_lookup[] = {
|
||||||
''')
|
''')
|
||||||
return ret
|
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):
|
def generate_enum(name, values):
|
||||||
lookup_decl = mcgen('''
|
lookup_decl = mcgen('''
|
||||||
extern const char *%(name)s_lookup[];
|
extern const char *%(name)s_lookup[];
|
||||||
|
|
|
@ -467,3 +467,13 @@ def guardend(name):
|
||||||
|
|
||||||
''',
|
''',
|
||||||
name=guardname(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()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue