blob: 48766f202829e16bd6aec0bdffc6721460677414 [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
Jack Jansenb81cf9d1995-06-06 13:08:40 +00004addpack.addpack(':Tools:bgen:bgen')
Guido van Rossume56db431995-03-19 22:49:50 +00005
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()
Jack Jansenb81cf9d1995-06-06 13:08:40 +000015
16 # Grmpf. Universal Headers have Text-stuff in a different include file...
17 input = "QuickDrawText.h"
18 output = "@qdgentext.py"
19 defsoutput = "@QuickDrawText.py"
20 have_extra = 0
21 try:
22 scanner = MyScanner(input, output, defsoutput)
23 scanner.scan()
24 scanner.close()
25 have_extra = 1
26 except IOError:
27 pass
28 if have_extra:
29 print "=== Copying QuickDrawText stuff into main files... ==="
30 ifp = open("@qdgentext.py")
31 ofp = open("qdgen.py", "a")
32 ofp.write(ifp.read())
33 ifp.close()
34 ofp.close()
35 ifp = open("@QuickDrawText.py")
36 ofp = open("QuickDraw.py", "a")
37 ofp.write(ifp.read())
38 ifp.close()
39 ofp.close()
40
Guido van Rossume56db431995-03-19 22:49:50 +000041 print "=== Done scanning and generating, now importing the generated code... ==="
42 import qdsupport
43 print "=== Done. It's up to you to compile it now! ==="
44
45class MyScanner(Scanner):
46
47 def destination(self, type, name, arglist):
48 classname = "Function"
49 listname = "functions"
50 if arglist:
51 t, n, m = arglist[0]
Jack Jansenb81cf9d1995-06-06 13:08:40 +000052 if t in ("WindowPtr", "WindowPeek", "WindowRef") and m == "InMode":
Guido van Rossume56db431995-03-19 22:49:50 +000053 classname = "Method"
54 listname = "methods"
55 return classname, listname
56
57 def makeblacklistnames(self):
58 return [
59 'InitGraf',
60 'StuffHex',
61 'StdLine',
62 'StdComment',
63 'StdGetPic',
64 'StdLine',
65 ]
66
67 def makeblacklisttypes(self):
68 return [
69 'BitMap_ptr',
70 'CCrsrHandle',
71 'CGrafPtr',
72 'CIconHandle',
73 'CQDProcs',
74 'CSpecArray',
75 'CTabHandle',
76 'ColorComplementProcPtr',
Jack Jansenb81cf9d1995-06-06 13:08:40 +000077 'ColorComplementUPP',
Guido van Rossume56db431995-03-19 22:49:50 +000078 'ColorSearchProcPtr',
Jack Jansenb81cf9d1995-06-06 13:08:40 +000079 'ColorSearchUPP',
Guido van Rossume56db431995-03-19 22:49:50 +000080 'ConstPatternParam',
81 'Cursor_ptr',
82 'DeviceLoopDrawingProcPtr',
83 'DeviceLoopFlags',
84 'FontInfo',
85 'GDHandle',
86 'GrafVerb',
87 'OpenCPicParams_ptr',
88 'PenState',
89 'PenState_ptr',
90 'Ptr',
91 'QDProcs',
92 'RGBColor',
93 'RGBColor_ptr',
94 'ReqListRec',
95 'void_ptr',
96 ]
97
98 def makerepairinstructions(self):
99 return [
100 ([('void_ptr', 'textBuf', 'InMode'),
101 ('short', 'firstByte', 'InMode'),
102 ('short', 'byteCount', 'InMode')],
103 [('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]),
104
105 ([('Point', '*', 'OutMode')],
106 [('*', '*', 'InOutMode')]),
107
108 ]
109
110if __name__ == "__main__":
111 main()