mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-25 19:46:25 +00:00
qapi: Simplify guardname()
The guards around built-in declarations lose their _H. It never made much sense anyway. Backports commit 00dfc3b2c272d98556ec6095d56bdd8b036babf9 from qemu
This commit is contained in:
parent
e100831af9
commit
6dcb71a788
1 changed files with 3 additions and 8 deletions
|
@ -957,14 +957,8 @@ def mcgen(code, **kwds):
|
||||||
code = code[1:]
|
code = code[1:]
|
||||||
return cgen(code, **kwds)
|
return cgen(code, **kwds)
|
||||||
|
|
||||||
def basename(filename):
|
|
||||||
return filename.split("/")[-1]
|
|
||||||
|
|
||||||
def guardname(filename):
|
def guardname(filename):
|
||||||
guard = basename(filename).rsplit(".", 1)[0]
|
return c_name(filename, protect=False).upper()
|
||||||
for substr in [".", " ", "-"]:
|
|
||||||
guard = guard.replace(substr, "_")
|
|
||||||
return guard.upper() + '_H'
|
|
||||||
|
|
||||||
def guardstart(name):
|
def guardstart(name):
|
||||||
return mcgen('''
|
return mcgen('''
|
||||||
|
@ -1034,6 +1028,7 @@ def parse_command_line(extra_options = "", extra_long_options = []):
|
||||||
|
|
||||||
def open_output(output_dir, do_c, do_h, prefix, c_file, h_file,
|
def open_output(output_dir, do_c, do_h, prefix, c_file, h_file,
|
||||||
c_comment, h_comment):
|
c_comment, h_comment):
|
||||||
|
guard = guardname(prefix + h_file)
|
||||||
c_file = output_dir + prefix + c_file
|
c_file = output_dir + prefix + c_file
|
||||||
h_file = output_dir + prefix + h_file
|
h_file = output_dir + prefix + h_file
|
||||||
|
|
||||||
|
@ -1066,7 +1061,7 @@ def open_output(output_dir, do_c, do_h, prefix, c_file, h_file,
|
||||||
#define %(guard)s
|
#define %(guard)s
|
||||||
|
|
||||||
''',
|
''',
|
||||||
comment = h_comment, guard = guardname(h_file)))
|
comment = h_comment, guard = guard))
|
||||||
|
|
||||||
return (fdef, fdecl)
|
return (fdef, fdecl)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue