[1c9540]: extract-jvmti / run.py Maximize Restore History

Download this file

run.py    38 lines (32 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from BeautifulSoup import *
import re
html = open('table.html', 'r').read()
soup = BeautifulSoup(html)
rows = soup.findAll('tr')
# skip the header
re_jnicall = re.compile("\(JNICALL \*(.*?)\)")
re_reserved = re.compile("void \*reserved[0-9]{1,3}")
functions = []
longest = 0
for row in rows[2:]:
cells = row.findAll('td')
num = int(cells[0].contents[0].strip())
signature = cells[2].contents[1].contents[0].replace("\n", "")
signature = re.sub("\s+", " ", signature)
jnicall = re_jnicall.search(signature)
if jnicall:
functions.append((num, signature, jnicall.group(1)))
if len(jnicall.group(1)) > longest:
longest = len(jnicall.group(1))
else:
reserved = re_reserved.search(signature)
if reserved:
functions.append((num, signature, "reserved%d" % num))
else:
print "Unknown signature: %d" % num
#print int(cells[0].contents[0].strip()), cells[2].contents[1].contents[0]
for num,sig,func in functions:
numspaces = longest - len(func)
print " private final static int %s%s = %d;" % (func.upper(),' '*numspaces, num-1)
#print ' names[%s]%s = "%s";' % (func.upper(), ' '*numspaces, func)
#print " %s" % sig