blob: 057db6dab01529f52611e55c8029aee45cac3b2b [file] [log] [blame]
Guido van Rossume56db431995-03-19 22:49:50 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3import addpack
4addpack.addpack('D:python:Tools:bgen:bgen')
5
6from scantools import Scanner
7
8def main():
9 input = "QuickDraw.h"
10 output = "qdgen.py"
11 defsoutput = "QuickDraw.py"
12 scanner = MyScanner(input, output, defsoutput)
13 scanner.scan()
14 scanner.close()
15 print "=== Done scanning and generating, now importing the generated code... ==="
16 import qdsupport
17 print "=== Done. It's up to you to compile it now! ==="
18
19class MyScanner(Scanner):
20
21 def destination(self, type, name, arglist):
22 classname = "Function"
23 listname = "functions"
24 if arglist:
25 t, n, m = arglist[0]
26 if t in ("WindowPtr", "WindowPeek") and m == "InMode":
27 classname = "Method"
28 listname = "methods"
29 return classname, listname
30
31 def makeblacklistnames(self):
32 return [
33 'InitGraf',
34 'StuffHex',
35 'StdLine',
36 'StdComment',
37 'StdGetPic',
38 'StdLine',
39 ]
40
41 def makeblacklisttypes(self):
42 return [
43 'BitMap_ptr',
44 'CCrsrHandle',
45 'CGrafPtr',
46 'CIconHandle',
47 'CQDProcs',
48 'CSpecArray',
49 'CTabHandle',
50 'ColorComplementProcPtr',
51 'ColorSearchProcPtr',
52 'ConstPatternParam',
53 'Cursor_ptr',
54 'DeviceLoopDrawingProcPtr',
55 'DeviceLoopFlags',
56 'FontInfo',
57 'GDHandle',
58 'GrafVerb',
59 'OpenCPicParams_ptr',
60 'PenState',
61 'PenState_ptr',
62 'Ptr',
63 'QDProcs',
64 'RGBColor',
65 'RGBColor_ptr',
66 'ReqListRec',
67 'void_ptr',
68 ]
69
70 def makerepairinstructions(self):
71 return [
72 ([('void_ptr', 'textBuf', 'InMode'),
73 ('short', 'firstByte', 'InMode'),
74 ('short', 'byteCount', 'InMode')],
75 [('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]),
76
77 ([('Point', '*', 'OutMode')],
78 [('*', '*', 'InOutMode')]),
79
80 ]
81
82if __name__ == "__main__":
83 main()