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