Skip to content

Commit 388ec8d

Browse files
cclaussBethGriggs
cclauss
authored andcommitted
tools: prepare tools/genv8constants.py for Python 3
PR-URL: #24801 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 039097e commit 388ec8d

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

tools/genv8constants.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
if len(sys.argv) != 3:
1717
print("usage: objsym.py outfile libv8_base.a")
18-
sys.exit(2);
18+
sys.exit(2)
1919

20-
outfile = file(sys.argv[1], 'w');
20+
outfile = open(sys.argv[1], 'w')
2121
try:
2222
pipe = subprocess.Popen([ 'objdump', '-z', '-D', sys.argv[2] ],
23-
bufsize=-1, stdout=subprocess.PIPE).stdout;
24-
except OSError, e:
23+
bufsize=-1, stdout=subprocess.PIPE).stdout
24+
except OSError as e:
2525
if e.errno == errno.ENOENT:
2626
print('''
2727
Node.js compile error: could not find objdump
@@ -33,9 +33,9 @@
3333

3434
sys.exit()
3535

36-
pattern = re.compile('([0-9a-fA-F]{8}|[0-9a-fA-F]{16}) <(.*)>:');
36+
pattern = re.compile('([0-9a-fA-F]{8}|[0-9a-fA-F]{16}) <(.*)>:')
3737
v8dbg = re.compile('^v8dbg.*$')
38-
numpattern = re.compile('^[0-9a-fA-F]{2} $');
38+
numpattern = re.compile('^[0-9a-fA-F]{2} $')
3939
octets = 4
4040

4141
outfile.write("""
@@ -49,28 +49,28 @@
4949
#ifndef V8_CONSTANTS_H
5050
#define V8_CONSTANTS_H
5151
52-
""");
52+
""")
5353

54-
curr_sym = None;
55-
curr_val = 0;
56-
curr_octet = 0;
54+
curr_sym = None
55+
curr_val = 0
56+
curr_octet = 0
5757

5858
def out_reset():
5959
global curr_sym, curr_val, curr_octet
60-
curr_sym = None;
61-
curr_val = 0;
62-
curr_octet = 0;
60+
curr_sym = None
61+
curr_val = 0
62+
curr_octet = 0
6363

6464
def out_define():
6565
global curr_sym, curr_val, curr_octet, outfile, octets
6666
if curr_sym != None:
67-
wrapped_val = curr_val & 0xffffffff;
67+
wrapped_val = curr_val & 0xffffffff
6868
if curr_val & 0x80000000 != 0:
69-
wrapped_val = 0x100000000 - wrapped_val;
70-
outfile.write("#define %s -0x%x\n" % (curr_sym.upper(), wrapped_val));
69+
wrapped_val = 0x100000000 - wrapped_val
70+
outfile.write("#define %s -0x%x\n" % (curr_sym.upper(), wrapped_val))
7171
else:
72-
outfile.write("#define %s 0x%x\n" % (curr_sym.upper(), wrapped_val));
73-
out_reset();
72+
outfile.write("#define %s 0x%x\n" % (curr_sym.upper(), wrapped_val))
73+
out_reset()
7474

7575
for line in pipe:
7676
if curr_sym != None:
@@ -81,35 +81,35 @@ def out_define():
8181
# much like hex numbers (e.g., "adc"), and we don't want to risk picking
8282
# those up by mistake, so we look at character-based columns instead.
8383
#
84-
for i in range (0, 3):
84+
for i in range(0, 3):
8585
# 6-character margin, 2-characters + 1 space for each field
86-
idx = 6 + i * 3;
86+
idx = 6 + i * 3
8787
octetstr = line[idx:idx+3]
8888
if curr_octet > octets:
89-
break;
89+
break
9090

9191
if not numpattern.match(octetstr):
92-
break;
92+
break
9393

94-
curr_val += int('0x%s' % octetstr, 16) << (curr_octet * 8);
95-
curr_octet += 1;
94+
curr_val += int('0x%s' % octetstr, 16) << (curr_octet * 8)
95+
curr_octet += 1
9696

9797
match = pattern.match(line)
9898
if match == None:
99-
continue;
99+
continue
100100

101101
# Print previous symbol
102-
out_define();
102+
out_define()
103103

104-
v8match = v8dbg.match(match.group(2));
104+
v8match = v8dbg.match(match.group(2))
105105
if v8match != None:
106-
out_reset();
107-
curr_sym = match.group(2);
106+
out_reset()
107+
curr_sym = match.group(2)
108108

109109
# Print last symbol
110-
out_define();
110+
out_define()
111111

112112
outfile.write("""
113113
114114
#endif /* V8_CONSTANTS_H */
115-
""");
115+
""")

0 commit comments

Comments
 (0)