blob: 83683feec21918ad4e05e3b01ea9a626e3d32dfc [file] [log] [blame]
Jack Jansencb4eaad1995-11-30 15:03:59 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3import addpack
4addpack.addpack(':tools:bgen:bgen')
5from scantools import Scanner
6
7LONG = "QuickTime"
8SHORT = "qt"
Jack Jansen453ced51995-11-30 17:42:08 +00009OBJECTS = ("Movie", "Track", "Media", "UserData", "TimeBase")
Jack Jansencb4eaad1995-11-30 15:03:59 +000010
11def main():
12 input = "Movies.h"
13 output = SHORT + "gen.py"
14 defsoutput = LONG + ".py"
15 scanner = MyScanner(input, output, defsoutput)
16 scanner.scan()
17 scanner.close()
18 print "=== Done scanning and generating, now importing the generated code... ==="
19 exec "import " + SHORT + "support"
20 print "=== Done. It's up to you to compile it now! ==="
21
22class MyScanner(Scanner):
23
24 def destination(self, type, name, arglist):
25 classname = "Function"
26 listname = "functions"
27 if arglist:
28 t, n, m = arglist[0]
Jack Jansen453ced51995-11-30 17:42:08 +000029 if t in OBJECTS and m == "InMode":
Jack Jansencb4eaad1995-11-30 15:03:59 +000030 classname = "Method"
Jack Jansen453ced51995-11-30 17:42:08 +000031 listname = t + "_methods"
Jack Jansencb4eaad1995-11-30 15:03:59 +000032 return classname, listname
33
34 def makeblacklistnames(self):
35 return [
36 "DisposeMovie", # Done on python-object disposal
Jack Jansen453ced51995-11-30 17:42:08 +000037 "DisposeMovieTrack", # ditto
38 "DisposeTrackMedia", # ditto
39 "DisposeUserData", # ditto
40 "DisposeTimeBase", # ditto
Jack Jansencb4eaad1995-11-30 15:03:59 +000041 "GetMovieCreationTime", # type "unsigned long" in C, inparseable
42 "GetMovieModificationTime", # Ditto
Jack Jansen453ced51995-11-30 17:42:08 +000043 "GetTrackCreationTime", # ditto
44 "GetTrackModificationTime", # Ditto
45 "GetMediaCreationTime", # ditto
46 "GetMediaModificationTime", # Ditto
47 # The following 4 use 'void *' in an uncontrolled way
48 # TBD when I've read the manual...
49 "GetUserDataItem",
50 "SetUserDataItem",
51 "SetTextSampleData",
52 "MCDoAction",
53 # bgen gets the argument in/out wrong..
54 "AddTextSample",
55 "AddTESample",
56 "AddHiliteSample",
57 "HiliteTextSample",
Jack Jansencb4eaad1995-11-30 15:03:59 +000058 ]
59
60 def makeblacklisttypes(self):
61 return [
Jack Jansen453ced51995-11-30 17:42:08 +000062 # I don't think we want to do these
63 "QTSyncTaskPtr",
64 # We dont do callbacks yet, so no need for these
Jack Jansencb4eaad1995-11-30 15:03:59 +000065 "QTCallBack",
Jack Jansen453ced51995-11-30 17:42:08 +000066 # Skipped for now, due to laziness
Jack Jansencb4eaad1995-11-30 15:03:59 +000067 "TimeRecord",
68 "TimeRecord_ptr",
69 "TrackEditState",
70 "MovieEditState",
Jack Jansencb4eaad1995-11-30 15:03:59 +000071 "MatrixRecord",
72 "MatrixRecord_ptr",
Jack Jansen453ced51995-11-30 17:42:08 +000073 "SampleReferencePtr",
74# "SampleDescription",
75# "SoundDescription",
76# "TextDescription",
77# "MusicDescription",
78 # I dont know yet how to do these.
79 "CGrafPtr",
80 "GDHandle",
81 # Routine pointers, not yet.
82 "MoviesErrorUPP",
83 "MoviePreviewCallOutUPP",
84 "MovieDrawingCompleteUPP",
Jack Jansencb4eaad1995-11-30 15:03:59 +000085 "QTCallBackUPP",
86 "TextMediaUPP",
87 "MovieProgressUPP",
88 "MovieRgnCoverUPP",
89 "MCActionFilterUPP",
90 "MCActionFilterWithRefConUPP",
Jack Jansen453ced51995-11-30 17:42:08 +000091 "GetMovieUPP",
92 "ModalFilterUPP",
Jack Jansencb4eaad1995-11-30 15:03:59 +000093 ]
94
95 def makerepairinstructions(self):
96 return [
Jack Jansen453ced51995-11-30 17:42:08 +000097 ([('FSSpec', '*', 'OutMode')], [('FSSpec_ptr', '*', 'InMode')]),
Jack Jansencb4eaad1995-11-30 15:03:59 +000098 ]
99
100if __name__ == "__main__":
101 main()