Support comment lines and missing indices in typeslots.h.

This commit is contained in:
Martin v. Löwis 2011-01-06 19:26:21 +00:00
parent c83bc3c1fb
commit b30111f29e
1 changed files with 6 additions and 1 deletions

View File

@ -7,6 +7,8 @@ print("/* Generated by typeslots.py $Revision$ */")
res = {}
for line in sys.stdin:
m = re.match("#define Py_([a-z_]+) ([0-9]+)", line)
if not m:
continue
member = m.group(1)
if member.startswith("tp_"):
member = "ht_type."+member
@ -22,4 +24,7 @@ for line in sys.stdin:
M = max(res.keys())+1
for i in range(1,M):
if i in res:
print("offsetof(PyHeapTypeObject, %s)," % res[i])
else:
print("0,")