source: trunk/essentials/dev-lang/python/Mac/Modules/qt/qtscan.py

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 11.8 KB
Line 
1# Scan an Apple header file, generating a Python file of generator calls.
2
3import sys
4import os
5from bgenlocations import TOOLBOXDIR, BGENDIR
6sys.path.append(BGENDIR)
7from scantools import Scanner
8
9LONG = "QuickTime"
10SHORT = "qt"
11HEADERFILES= (
12# "Components.h" -- In Carbon.Cm
13 "Movies.h",
14 "ImageCompression.h",
15 "QuickTimeComponents.h",
16# "ImageCodec.h" -- seems not too useful, and difficult.
17# "IsochronousDataHandlers.h" -- Is this useful?
18 "MediaHandlers.h",
19# "QTML.h", -- Windows only, needs separate module
20# "QuickTimeStreaming.h", -- Difficult
21# "QTStreamingComponents.h", -- Needs QTStreaming
22 "QuickTimeMusic.h",
23# "QuickTimeVR.h", -- Not done yet
24# "Sound.h", -- In Carbon.Snd
25 )
26OBJECTS = ("Movie", "Track", "Media", "UserData", "TimeBase", "MovieController",
27 "IdleManager", "SGOutput")
28
29def main():
30 input = HEADERFILES
31 output = SHORT + "gen.py"
32 defsoutput = TOOLBOXDIR + LONG + ".py"
33 scanner = MyScanner(input, output, defsoutput)
34 scanner.scan()
35 scanner.close()
36 scanner.gentypetest(SHORT+"typetest.py")
37 print "=== Testing definitions output code ==="
38 execfile(defsoutput, {}, {})
39 print "=== Done scanning and generating, now importing the generated code... ==="
40 exec "import " + SHORT + "support"
41 print "=== Done. It's up to you to compile it now! ==="
42
43class MyScanner(Scanner):
44
45 def destination(self, type, name, arglist):
46 classname = "Function"
47 listname = "functions"
48 if arglist:
49 t, n, m = arglist[0]
50 if t in OBJECTS and m == "InMode":
51 classname = "Method"
52 listname = t + "_methods"
53 return classname, listname
54
55 def writeinitialdefs(self):
56 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
57 self.defsfile.write("xmlIdentifierUnrecognized = -1\n")
58 self.defsfile.write("kControllerMinimum = -0xf777\n")
59 self.defsfile.write("notImplementedMusicOSErr = -2071\n")
60 self.defsfile.write("cantSendToSynthesizerOSErr = -2072\n")
61 self.defsfile.write("cantReceiveFromSynthesizerOSErr = -2073\n")
62 self.defsfile.write("illegalVoiceAllocationOSErr = -2074\n")
63 self.defsfile.write("illegalPartOSErr = -2075\n")
64 self.defsfile.write("illegalChannelOSErr = -2076\n")
65 self.defsfile.write("illegalKnobOSErr = -2077\n")
66 self.defsfile.write("illegalKnobValueOSErr = -2078\n")
67 self.defsfile.write("illegalInstrumentOSErr = -2079\n")
68 self.defsfile.write("illegalControllerOSErr = -2080\n")
69 self.defsfile.write("midiManagerAbsentOSErr = -2081\n")
70 self.defsfile.write("synthesizerNotRespondingOSErr = -2082\n")
71 self.defsfile.write("synthesizerOSErr = -2083\n")
72 self.defsfile.write("illegalNoteChannelOSErr = -2084\n")
73 self.defsfile.write("noteChannelNotAllocatedOSErr = -2085\n")
74 self.defsfile.write("tunePlayerFullOSErr = -2086\n")
75 self.defsfile.write("tuneParseOSErr = -2087\n")
76
77 def makeblacklistnames(self):
78 return [
79 "xmlIdentifierUnrecognized", # const with incompatible definition
80 "DisposeMovie", # Done on python-object disposal
81 "DisposeMovieTrack", # ditto
82 "DisposeTrackMedia", # ditto
83 "DisposeUserData", # ditto
84# "DisposeTimeBase", # ditto
85 "DisposeMovieController", # ditto
86
87 # The following 4 use 'void *' in an uncontrolled way
88 # TBD when I've read the manual...
89 "GetUserDataItem",
90 "SetUserDataItem",
91 "SetTextSampleData",
92 "BeginFullScreen",
93 # bgen gets the argument in/out wrong..
94 "AddTextSample",
95 "AddTESample",
96 "AddHiliteSample",
97 "HiliteTextSample",
98
99 "MakeTrackTimeTable", # Uses long * return?
100 "MakeMediaTimeTable", # ditto
101## "VideoMediaGetStallCount", # Undefined in CW Pro 3 library
102 # OS8 only:
103 'SpriteMediaGetIndImageProperty', # XXXX Why isn't this in carbon?
104 'CheckQuickTimeRegistration',
105 'SetMovieAnchorDataRef',
106 'GetMovieAnchorDataRef',
107 'GetMovieLoadState',
108 'OpenADataHandler',
109 'MovieMediaGetCurrentMovieProperty',
110 'MovieMediaGetCurrentTrackProperty',
111 'MovieMediaGetChildMovieDataReference',
112 'MovieMediaSetChildMovieDataReference',
113 'MovieMediaLoadChildMovieFromDataReference',
114 'Media3DGetViewObject',
115
116 # these are ImageCompression blacklists
117 "GraphicsExportGetInputPtr",
118
119 # QuickTimeComponents
120 # These two need some help: the first returns a point to a databuffer that
121 # the second disposes. Generate manually?
122 "VDCompressDone",
123 "VDReleaseCompressBuffer",
124 "QTVideoOutputGetGWorldParameters", # How useful is this?
125
126 # MediaHandlers
127 "MediaMakeMediaTimeTable", # just lazy
128 "MediaGetSampleDataPointer", # funny output pointer
129
130 # QuickTimeMusic
131 "kControllerMinimum",
132 # These are artefacts of a macro definition
133 "ulen",
134 "_ext",
135 "x",
136 "w1",
137 "w2",
138 ]
139
140 def makeblacklisttypes(self):
141 return [
142 # I don't think we want to do these
143 "QTSyncTaskPtr",
144 # We dont do callbacks yet, so no need for these
145 "QTCallBack",
146 # Skipped for now, due to laziness
147 "TrackEditState",
148 "MovieEditState",
149 "MatrixRecord",
150 "MatrixRecord_ptr",
151 "SampleReferencePtr",
152 "QTTweener",
153 "QTErrorReplacementPtr",
154 "QTRestrictionSet",
155 "QTUUID",
156 "QTUUID_ptr",
157
158 # Routine pointers, not yet.
159 "MoviesErrorUPP",
160 "MoviePreviewCallOutUPP",
161 "MovieDrawingCompleteUPP",
162 "QTCallBackUPP",
163 "TextMediaUPP",
164 "MovieProgressUPP",
165 "MovieRgnCoverUPP",
166 "MCActionFilterUPP",
167 "MCActionFilterWithRefConUPP",
168 "GetMovieUPP",
169 "ModalFilterUPP",
170 "TrackTransferUPP",
171 "MoviePrePrerollCompleteUPP",
172 "MovieExecuteWiredActionsUPP",
173 "QTBandwidthNotificationUPP",
174 "DoMCActionUPP",
175 "QTNextTaskNeededSoonerCallbackUPP",
176
177 "SampleReference64Ptr", # Don't know what this does, yet
178 "QTRuntimeSpriteDescPtr",
179 "QTBandwidthReference",
180 "QTScheduledBandwidthReference",
181 "QTAtomContainer",
182 "SpriteWorld",
183 "Sprite",
184
185 # these are ImageCompression blacklists
186 "ICMDataUPP",
187 "ICMFlushUPP",
188 "ICMCompletionUPP",
189 "ICMProgressUPP",
190 "StdPixUPP",
191 "QDPixUPP",
192 "ICMAlignmentUPP",
193 "ICMCursorShieldedUPP",
194 "ICMMemoryDisposedUPP",
195 "ICMConvertDataFormatUPP",
196 "ModalFilterYDUPP",
197 "FileFilterUPP",
198
199 "CodecNameSpecListPtr",
200 "CodecInfo",
201 "ImageSequence",
202 "MatrixRecordPtr",
203 "ICMDataProcRecordPtr",
204 "OpenCPicParams",
205 "ICMProgressProcRecordPtr",
206 "ICMAlignmentProcRecordPtr",
207 "ICMPixelFormatInfoPtr",
208 "ImageSequenceDataSource",
209 "ConstStrFileNameParam",
210 "ImageTranscodeSequence",
211 "ImageFieldSequence",
212 "Fract",
213 "PixMapPtr",
214 "GWorldFlags",
215 "void_ptr", # XXX Being lazy, this one is doable.
216
217 # These are from QuickTimeComponents
218 "CDataHandlerUPP",
219 "CharDataHandlerUPP",
220 "CommentHandlerUPP",
221 "DataHCompletionUPP",
222 "'MovieExportGetDataUPP",
223 "MovieExportGetPropertyUPP",
224 "PreprocessInstructionHandlerUPP",
225 "SGModalFilterUPP",
226 "StartDocumentHandlerUPP",
227 "StartElementHandlerUPP",
228 "VdigIntUPP",
229 "SGDataUPP",
230 "EndDocumentHandlerUPP",
231 "EndElementHandlerUPP",
232 "VideoBottles", # Record full of UPPs
233
234 "SCParams",
235 "ICMCompletionProcRecordPtr",
236 "DataHVolumeList",
237 "DigitizerInfo",
238 "SGCompressInfo",
239 "SeqGrabExtendedFrameInfoPtr",
240 "SeqGrabFrameInfoPtr",
241 "TCTextOptionsPtr",
242 "SGCompressInfo_ptr",
243 "SGDeviceList",
244 "TextDisplayData",
245 "TimeCodeDef",
246 "TimeCodeRecord",
247 "TweenRecord",
248 "VDGamRecPtr",
249 "ToneDescription", # XXXX Just lazy: this one is easy.
250 "XMLDoc",
251 "UInt64", # XXXX lazy
252 "UInt64_ptr", # XXXX lazy
253
254 # From MediaHandlers
255 "ActionsUPP",
256 "PrePrerollCompleteUPP",
257 "CodecComponentHandle", # Difficult: handle containing list of components.
258 "GetMovieCompleteParams", # Immense struct
259 "LevelMeterInfoPtr", # Lazy. Also: can be an output parameter!!
260 "MediaEQSpectrumBandsRecordPtr", # ditto
261
262 # From QuickTimeMusic
263 "MusicMIDISendUPP",
264 "MusicOfflineDataUPP",
265 "TuneCallBackUPP",
266 "TunePlayCallBackUPP",
267 "GCPart", # Struct with lots of fields
268 "GCPart_ptr",
269 "GenericKnobDescription", # Struct with lots of fields
270 "KnobDescription", # Struct with lots of fields
271 "InstrumentAboutInfo", # Struct, not too difficult
272 "NoteChannel", # XXXX Lazy. Could be opaque, I think
273 "NoteRequest", # XXXX Lazy. Not-too-difficult struct
274 "SynthesizerConnections", # Struct with lots of fields
275 "SynthesizerDescription", # Struct with lots of fields
276 "TuneStatus", # Struct with lots of fields
277
278 ]
279
280 def makerepairinstructions(self):
281 return [
282 ([('FSSpec', '*', 'OutMode')], [('FSSpec_ptr', '*', 'InMode')]),
283
284 # Movie controller creation
285 ([('ComponentInstance', 'NewMovieController', 'ReturnMode')],
286 [('MovieController', '*', 'ReturnMode')]),
287
288 # NewMovieFromFile
289 ([('short', 'resId', 'OutMode'), ('StringPtr', 'resName', 'InMode')],
290 [('short', 'resId', 'InOutMode'), ('dummyStringPtr', 'resName', 'InMode')]),
291
292 # MCDoAction and more
293 ([('void', '*', 'OutMode')], [('mcactionparams', '*', 'InMode')]),
294
295 # SetTimeBaseZero. Does not handle NULLs, unfortunately
296 ([('TimeRecord', 'zero', 'OutMode')], [('TimeRecord', 'zero', 'InMode')]),
297
298 # ConvertTime and ConvertTimeScale
299 ([('TimeRecord', 'inout', 'OutMode')], [('TimeRecord', 'inout', 'InOutMode')]),
300 ([('TimeRecord', 'theTime', 'OutMode')], [('TimeRecord', 'theTime', 'InOutMode')]),
301
302 # AddTime and SubtractTime
303 ([('TimeRecord', 'dst', 'OutMode')], [('TimeRecord', 'dst', 'InOutMode')]),
304
305 # Funny definitions
306 ([('char_ptr', '*', 'InMode')], [('stringptr', '*', 'InMode')]),
307 ([('FSSpecPtr', '*', 'InMode')], [('FSSpec_ptr', '*', 'InMode')]),
308 ([('unsigned_char', 'swfVersion', 'OutMode')], [('UInt8', 'swfVersion', 'OutMode')]),
309
310 # It seems MusicMIDIPacket if never flagged with const but always used
311 # for sending only. If that ever changes this needs to be fixed.
312 ([('MusicMIDIPacket', '*', 'OutMode')], [('MusicMIDIPacket_ptr', '*', 'InMode')]),
313
314 # QTMusic const-less input parameters
315 ([('unsigned_long', 'header', 'OutMode')], [('UnsignedLongPtr', 'header', 'InMode')]),
316 ]
317
318if __name__ == "__main__":
319 main()
Note: See TracBrowser for help on using the repository browser.