summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/h2py.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/scripts/h2py.py')
-rwxr-xr-xTools/scripts/h2py.py26
1 files changed, 9 insertions, 17 deletions
diff --git a/Tools/scripts/h2py.py b/Tools/scripts/h2py.py
index c681e23..45aa439 100755
--- a/Tools/scripts/h2py.py
+++ b/Tools/scripts/h2py.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# Read #define's and translate to Python code.
# Handle #include statements.
@@ -49,15 +49,7 @@ except KeyError:
try:
searchdirs=os.environ['INCLUDE'].split(';')
except KeyError:
- try:
- if sys.platform.find("beos") == 0:
- searchdirs=os.environ['BEINCLUDES'].split(';')
- elif sys.platform.startswith("atheos"):
- searchdirs=os.environ['C_INCLUDE_PATH'].split(':')
- else:
- raise KeyError
- except KeyError:
- searchdirs=['/usr/include']
+ searchdirs=['/usr/include']
def main():
global filedict
@@ -98,13 +90,13 @@ def pytify(body):
body = p_char.sub("ord('\\1')", body)
# Compute negative hexadecimal constants
start = 0
- UMAX = 2*(sys.maxint+1)
+ UMAX = 2*(sys.maxsize+1)
while 1:
m = p_hex.search(body, start)
if not m: break
s,e = m.span()
- val = long(body[slice(*m.span(1))], 16)
- if val > sys.maxint:
+ val = int(body[slice(*m.span(1))], 16)
+ if val > sys.maxsize:
val -= UMAX
body = body[:s] + "(" + str(val) + ")" + body[e:]
start = s + 1
@@ -130,7 +122,7 @@ def process(fp, outfp, env = {}):
ok = 0
stmt = '%s = %s\n' % (name, body.strip())
try:
- exec stmt in env
+ exec(stmt, env)
except:
sys.stderr.write('Skipping: %s' % stmt)
else:
@@ -142,7 +134,7 @@ def process(fp, outfp, env = {}):
body = pytify(body)
stmt = 'def %s(%s): return %s\n' % (macro, arg, body)
try:
- exec stmt in env
+ exec(stmt, env)
except:
sys.stderr.write('Skipping: %s' % stmt)
else:
@@ -152,9 +144,9 @@ def process(fp, outfp, env = {}):
regs = match.regs
a, b = regs[1]
filename = line[a:b]
- if importable.has_key(filename):
+ if filename in importable:
outfp.write('from %s import *\n' % importable[filename])
- elif not filedict.has_key(filename):
+ elif filename not in filedict:
filedict[filename] = None
inclfp = None
for dir in searchdirs: