Skip to content

Commit 022599c

Browse files
cclaussMylesBorins
authored andcommitted
tools: prepare tools/genv8constants.py for Python 3
PR-URL: #24801 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 6137674 commit 022599c

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

‎tools/genv8constants.py‎

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
iflen(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-
exceptOSError,e:
23+
bufsize=-1, stdout=subprocess.PIPE).stdout
24+
exceptOSErrorase:
2525
ife.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
defout_reset():
5959
globalcurr_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
defout_define():
6565
globalcurr_sym, curr_val, curr_octet, outfile, octets
6666
ifcurr_sym!=None:
67-
wrapped_val=curr_val&0xffffffff;
67+
wrapped_val=curr_val&0xffffffff
6868
ifcurr_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
forlineinpipe:
7676
ifcurr_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-
foriinrange(0, 3):
84+
foriinrange(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
ifcurr_octet>octets:
89-
break;
89+
break
9090

9191
ifnotnumpattern.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
ifmatch==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
ifv8match!=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)