changes by Barry, e.g. font lock & email addresses
[python/dscho.git] / Mac / Modules / qd / qdscan.py
blob0e03d7714303a042078245eeb975e63876c0c56d
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import addpack
4 addpack.addpack(':Tools:bgen:bgen')
6 from scantools import Scanner
8 def 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()
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()
41 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! ==="
45 class MyScanner(Scanner):
47 def destination(self, type, name, arglist):
48 classname = "Function"
49 listname = "functions"
50 if arglist:
51 t, n, m = arglist[0]
52 if t in ("WindowPtr", "WindowPeek", "WindowRef") and m == "InMode":
53 classname = "Method"
54 listname = "methods"
55 return classname, listname
57 def makeblacklistnames(self):
58 return [
59 'InitGraf',
60 'StuffHex',
61 'StdLine',
62 'StdComment',
63 'StdGetPic',
64 'StdLine',
67 def makeblacklisttypes(self):
68 return [
69 'BitMap_ptr',
70 'CCrsrHandle',
71 'CGrafPtr',
72 'CIconHandle',
73 'CQDProcs',
74 'CSpecArray',
75 'CTabHandle',
76 'ColorComplementProcPtr',
77 'ColorComplementUPP',
78 'ColorSearchProcPtr',
79 'ColorSearchUPP',
80 'ConstPatternParam',
81 'Pattern_ptr',
82 'Cursor_ptr',
83 'DeviceLoopDrawingProcPtr',
84 'DeviceLoopFlags',
85 'FontInfo',
86 'GDHandle',
87 'GrafVerb',
88 'OpenCPicParams_ptr',
89 'PenState',
90 'PenState_ptr',
91 'Ptr',
92 'QDProcs',
93 'RGBColor',
94 'RGBColor_ptr',
95 'ReqListRec',
96 'void_ptr',
99 def makerepairinstructions(self):
100 return [
101 ([('void_ptr', 'textBuf', 'InMode'),
102 ('short', 'firstByte', 'InMode'),
103 ('short', 'byteCount', 'InMode')],
104 [('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]),
106 ([('Point', '*', 'OutMode')],
107 [('*', '*', 'InOutMode')]),
111 if __name__ == "__main__":
112 main()