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',
104 'HandleToRgn', # Funny signature
106 # Need Cm, which we don't want to drag in just yet
107 'OpenCursorComponent',
108 'CloseCursorComponent',
109 'SetCursorComponent',
110 'CursorComponentChanged',
111 'CursorComponentSetData',
114 def makegreylist(self
):
116 ('#if !TARGET_API_MAC_CARBON', [
118 ('#if TARGET_API_MAC_CARBON', [
119 'IsPortOffscreen', # Lazy
120 'IsPortColor', # Lazy
121 'IsRegionRectangular',
125 'IsPortPolyBeingDefined',
133 def makeblacklisttypes(self
):
135 'CIconHandle', # Obsolete
139 'ColorComplementProcPtr',
140 'ColorComplementUPP',
141 'ColorSearchProcPtr',
144 'DeviceLoopDrawingProcPtr',
147 'OpenCPicParams_ptr',
155 def makerepairinstructions(self
):
157 ([('void_ptr', 'textBuf', 'InMode'),
158 ('short', 'firstByte', 'InMode'),
159 ('short', 'byteCount', 'InMode')],
160 [('TextThingie', '*', '*'), ('*', '*', '*'), ('*', '*', '*')]),
162 # GetPen and SetPt use a point-pointer as output-only:
163 ('GetPen', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]),
164 ('SetPt', [('Point', '*', 'OutMode')], [('*', '*', 'OutMode')]),
166 # All others use it as input/output:
167 ([('Point', '*', 'OutMode')],
168 [('*', '*', 'InOutMode')]),
170 # InsetRect, OffsetRect
171 ([('Rect', 'r', 'OutMode'),
172 ('short', 'dh', 'InMode'),
173 ('short', 'dv', 'InMode')],
174 [('Rect', 'r', 'InOutMode'),
175 ('short', 'dh', 'InMode'),
176 ('short', 'dv', 'InMode')]),
179 ([('Rect', 'r', 'OutMode'),
180 ('Rect_ptr', 'srcRect', 'InMode'),
181 ('Rect_ptr', 'dstRect', 'InMode')],
182 [('Rect', 'r', 'InOutMode'),
183 ('Rect_ptr', 'srcRect', 'InMode'),
184 ('Rect_ptr', 'dstRect', 'InMode')]),
186 # CopyBits and friends
187 ([('RgnHandle', 'maskRgn', 'InMode')],
188 [('OptRgnHandle', 'maskRgn', 'InMode')]),
190 ('QDFlushPortBuffer',
191 [('RgnHandle', '*', 'InMode')],
192 [('OptRgnHandle', '*', 'InMode')]),
194 # Accessors with reference argument also returned.
195 ([('Rect_ptr', 'GetPortBounds', 'ReturnMode')],
196 [('void', '*', 'ReturnMode')]),
198 ([('RGBColor_ptr', 'GetPortForeColor', 'ReturnMode')],
199 [('void', '*', 'ReturnMode')]),
201 ([('RGBColor_ptr', 'GetPortBackColor', 'ReturnMode')],
202 [('void', '*', 'ReturnMode')]),
204 ([('RGBColor_ptr', 'GetPortOpColor', 'ReturnMode')],
205 [('void', '*', 'ReturnMode')]),
207 ([('RGBColor_ptr', 'GetPortHiliteColor', 'ReturnMode')],
208 [('void', '*', 'ReturnMode')]),
210 ([('Point_ptr', 'GetPortPenSize', 'ReturnMode')],
211 [('void', '*', 'ReturnMode')]),
213 ([('Point_ptr', 'GetPortPenLocation', 'ReturnMode')],
214 [('void', '*', 'ReturnMode')]),
216 ([('Rect_ptr', 'GetPixBounds', 'ReturnMode')],
217 [('void', '*', 'ReturnMode')]),
219 ([('BitMap_ptr', 'GetQDGlobalsScreenBits', 'ReturnMode')],
220 [('void', '*', 'ReturnMode')]),
222 ([('Cursor_ptr', 'GetQDGlobalsArrow', 'ReturnMode')],
223 [('void', '*', 'ReturnMode')]),
225 ([('Rect_ptr', 'GetRegionBounds', 'ReturnMode')],
226 [('void', '*', 'ReturnMode')]),
228 ([('Pattern_ptr', '*', 'ReturnMode')],
229 [('void', '*', 'ReturnMode')]),
233 if __name__
== "__main__":