mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 10:35:27 +00:00
python: better support for Python3 (adapted from Capstone code)
This commit is contained in:
parent
d13a4197f1
commit
d93210ad5a
|
@ -66,8 +66,8 @@ def gen(lang):
|
||||||
templ = template[lang]
|
templ = template[lang]
|
||||||
for target in include:
|
for target in include:
|
||||||
prefix = templ[target]
|
prefix = templ[target]
|
||||||
outfile = open(templ['out_file'] %(prefix), 'w')
|
outfile = open(templ['out_file'] %(prefix), 'wb') # open as binary prevents windows newlines
|
||||||
outfile.write(templ['header'] % (prefix))
|
outfile.write((templ['header'] % (prefix)).encode("utf-8"))
|
||||||
if target == 'unicorn.h':
|
if target == 'unicorn.h':
|
||||||
prefix = ''
|
prefix = ''
|
||||||
lines = open(INCL_DIR + target).readlines()
|
lines = open(INCL_DIR + target).readlines()
|
||||||
|
@ -78,8 +78,8 @@ def gen(lang):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
|
||||||
if line.startswith(MARKUP): # markup for comments
|
if line.startswith(MARKUP): # markup for comments
|
||||||
outfile.write("\n%s%s%s\n" %(templ['comment_open'], \
|
outfile.write(("\n%s%s%s\n" %(templ['comment_open'], \
|
||||||
line.replace(MARKUP, ''), templ['comment_close']))
|
line.replace(MARKUP, ''), templ['comment_close'])).encode("utf-8"))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if line == '' or line.startswith('//'):
|
if line == '' or line.startswith('//'):
|
||||||
|
@ -126,12 +126,12 @@ def gen(lang):
|
||||||
lhs_strip = re.sub(r'^UC_', '', lhs)
|
lhs_strip = re.sub(r'^UC_', '', lhs)
|
||||||
count = int(rhs) + 1
|
count = int(rhs) + 1
|
||||||
if (count == 1):
|
if (count == 1):
|
||||||
outfile.write("\n")
|
outfile.write(("\n").encode("utf-8"))
|
||||||
|
|
||||||
outfile.write(templ['line_format'] % (lhs_strip, rhs))
|
outfile.write((templ['line_format'] % (lhs_strip, rhs)).encode("utf-8"))
|
||||||
previous[lhs] = str(rhs)
|
previous[lhs] = str(rhs)
|
||||||
|
|
||||||
outfile.write(templ['footer'])
|
outfile.write((templ['footer']).encode("utf-8"))
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -323,8 +323,7 @@ def debug():
|
||||||
|
|
||||||
all_archs = ""
|
all_archs = ""
|
||||||
keys = archs.keys()
|
keys = archs.keys()
|
||||||
keys.sort()
|
for k in sorted(keys):
|
||||||
for k in keys:
|
|
||||||
if uc_arch_supported(archs[k]):
|
if uc_arch_supported(archs[k]):
|
||||||
all_archs += "-%s" % k
|
all_archs += "-%s" % k
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue