Jack Jansen | cb4eaad | 1995-11-30 15:03:59 +0000 | [diff] [blame] | 1 | # Scan an Apple header file, generating a Python file of generator calls. |
| 2 | |
| 3 | import addpack |
| 4 | addpack.addpack(':tools:bgen:bgen') |
| 5 | from scantools import Scanner |
| 6 | |
| 7 | LONG = "QuickTime" |
| 8 | SHORT = "qt" |
| 9 | OBJECT = "Movie" |
| 10 | |
| 11 | def 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 | |
| 22 | class 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] |
| 29 | if t == OBJECT and m == "InMode": |
| 30 | classname = "Method" |
| 31 | listname = "methods" |
| 32 | return classname, listname |
| 33 | |
| 34 | def makeblacklistnames(self): |
| 35 | return [ |
| 36 | "DisposeMovie", # Done on python-object disposal |
| 37 | "GetMovieCreationTime", # type "unsigned long" in C, inparseable |
| 38 | "GetMovieModificationTime", # Ditto |
| 39 | ] |
| 40 | |
| 41 | def makeblacklisttypes(self): |
| 42 | return [ |
| 43 | "MoviesErrorUPP", |
| 44 | "Track", # XXXX To be done in the future |
| 45 | "Media", |
| 46 | "UserData", |
| 47 | "TimeBase", |
| 48 | "QTCallBack", |
| 49 | "Component", |
| 50 | "TimeRecord", |
| 51 | "TimeRecord_ptr", |
| 52 | "TrackEditState", |
| 53 | "MovieEditState", |
| 54 | "MoviePreviewCallOutUPP", |
| 55 | "CGrafPtr", |
| 56 | "GDHandle", |
| 57 | "MovieDrawingCompleteUPP", |
| 58 | "PixMapHandle", |
| 59 | "MatrixRecord", |
| 60 | "MatrixRecord_ptr", |
| 61 | "QTCallBackUPP", |
| 62 | "TextMediaUPP", |
| 63 | "MovieProgressUPP", |
| 64 | "MovieRgnCoverUPP", |
| 65 | "MCActionFilterUPP", |
| 66 | "MCActionFilterWithRefConUPP", |
| 67 | "SampleDescription", |
| 68 | "SoundDescription", |
| 69 | "TextDescription", |
| 70 | "MusicDescription", |
| 71 | ] |
| 72 | |
| 73 | def makerepairinstructions(self): |
| 74 | return [ |
| 75 | ] |
| 76 | |
| 77 | if __name__ == "__main__": |
| 78 | main() |