7 rx = re.compile(r'^\s*([\w\s\*]+)\(\s*\*\s*(\w+)\s*\)\s*\(([^()]*)\);',
8 re.DOTALL|re.MULTILINE)
12 for m in rx.findall(buf):
13 return_type = m[0].strip()
14 if 'typedef' in return_type:
16 if return_type == 'void':
18 return_type = return_type.replace(' ', '')
20 if 'reserved' in virtual_name:
24 print >> sys.stderr, repr(m)
26 for param in map(str.strip, m[2].split(',')):
28 tokens = param.split('*')
29 ptype = tokens[0].strip() + '*'*(len(tokens) - 1)
30 pname = tokens[-1].strip()
34 ptype, pname = map(str.strip, param.split())
35 ptype = ptype.replace('const ', 'const-')
37 pname = pname.replace('[]', '')
39 params.append((ptype, pname))
42 objname = params[0][0].replace('*', '')
43 print '(define-virtual', virtual_name
44 print ' (of-object "%s")' % objname
45 print ' (return-type "%s")' % return_type
48 for param in params[1:]:
49 print ' \'("%s" "%s")' % param
53 if __name__ == '__main__':