summaryrefslogtreecommitdiffstats
path: root/PC/python35gen.py
blob: 609cb9d22f8c6ff397a7a1945f56c376799c0825 (plain)
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
# Generate python35stub.def out of python3.def
# The regular import library cannot be used,
# since it doesn't provide the right symbols for
# data forwarding
out = open("python35stub.def", "w")
out.write('LIBRARY "python35"\n')
out.write('EXPORTS\n')

inp = open("python3.def")
line = inp.readline()
while line.strip().startswith(';'):
    line = inp.readline()
line = inp.readline() # LIBRARY
assert line.strip()=='EXPORTS'

for line in inp:
    # SYM1=python35.SYM2[ DATA]
    head, tail = line.split('.')
    if 'DATA' in tail:
        symbol, tail = tail.split(' ')
    else:
        symbol = tail.strip()
    out.write(symbol+'\n')

inp.close()
out.close()