1 # Scan an Apple header file, generating a Python file of generator calls.
5 BGENDIR
=os
.path
.join(sys
.prefix
, ':Tools:bgen:bgen')
6 sys
.path
.append(BGENDIR
)
8 from scantools
import Scanner
9 from bgenlocations
import TOOLBOXDIR
14 defsoutput
= TOOLBOXDIR
+ "QuickDraw.py"
15 scanner
= MyScanner(input, output
, defsoutput
)
19 # Grmpf. Universal Headers have Text-stuff in a different include file...
20 input = "QuickDrawText.h"
21 output
= "@qdgentext.py"
22 defsoutput
= "@QuickDrawText.py"
25 scanner
= MyScanner(input, output
, defsoutput
)
32 print "=== Copying QuickDrawText stuff into main files... ==="
33 ifp
= open("@qdgentext.py")
34 ofp
= open("qdgen.py", "a")
38 ifp
= open("@QuickDrawText.py")
39 ofp
= open(TOOLBOXDIR
+ "QuickDraw.py", "a")
44 print "=== Done scanning and generating, now importing the generated code... ==="
46 print "=== Done. It's up to you to compile it now! ==="
48 class MyScanner(Scanner
):
50 def destination(self
, type, name
, arglist
):
51 classname
= "Function"
52 listname
= "functions"
55 ## elif t == "PolyHandle" and m == "InMode":
56 ## classname = "Method"
57 ## listname = "p_methods"
58 ## elif t == "RgnHandle" and m == "InMode":
59 ## classname = "Method"
60 ## listname = "r_methods"
61 return classname
, listname
64 def writeinitialdefs(self
):
65 self
.defsfile
.write("""
66 def FOUR_CHAR_CODE(x): return x
77 def makeblacklistnames(self
):
91 'StdOpcode', # XXXX Missing from library...
92 # The following are for non-macos use:
96 'GetPortNativeWindow',
97 'GetNativeWindowPort',
98 'NativeRegionToMacRegion',
99 'MacRegionToNativeRegion',
107 def makeblacklisttypes(self
):
110 'CIconHandle', # Obsolete
114 'ColorComplementProcPtr',
115 'ColorComplementUPP',
116 'ColorSearchProcPtr',
119 'DeviceLoopDrawingProcPtr',
124 'OpenCPicParams_ptr',
131 def makerepairinstructions(self
):
133 ([('void_ptr', 'textBuf', 'InMode'),
134 ('short', 'firstByte', 'InMode'),
135 ('short', 'byteCount', 'InMode')],
136 [('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]),
138 # GetPen and SetPt use a point-pointer as output-only:
139 ('GetPen', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]),
140 ('SetPt', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]),
142 # All others use it as input/output:
143 ([('Point', '*', 'OutMode')],
144 [('*', '*', 'InOutMode')]),
146 # InsetRect, OffsetRect
147 ([('Rect', 'r', 'OutMode'),
148 ('short', 'dh', 'InMode'),
149 ('short', 'dv', 'InMode')],
150 [('Rect', 'r', 'InOutMode'),
151 ('short', 'dh', 'InMode'),
152 ('short', 'dv', 'InMode')]),
155 ([('Rect', 'r', 'OutMode'),
156 ('Rect_ptr', 'srcRect', 'InMode'),
157 ('Rect_ptr', 'dstRect', 'InMode')],
158 [('Rect', 'r', 'InOutMode'),
159 ('Rect_ptr', 'srcRect', 'InMode'),
160 ('Rect_ptr', 'dstRect', 'InMode')]),
162 # CopyBits and friends
163 ([('RgnHandle', 'maskRgn', 'InMode')],
164 [('OptRgnHandle', 'maskRgn', 'InMode')]),
168 if __name__
== "__main__":