Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1 | # Scan Sound.h header file, generate sndgen.py and Sound.py files. |
| 2 | # Then import sndsupport (which execs sndgen.py) to generate Sndmodule.c. |
| 3 | # (Should learn how to tell the compiler to compile it as well.) |
| 4 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 5 | import addpack |
| 6 | addpack.addpack(':Tools:bgen:bgen') |
| 7 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 8 | from scantools import Scanner |
| 9 | |
| 10 | def main(): |
| 11 | input = "Sound.h" |
| 12 | output = "sndgen.py" |
| 13 | defsoutput = "Sound.py" |
| 14 | scanner = SoundScanner(input, output, defsoutput) |
| 15 | scanner.scan() |
| 16 | scanner.close() |
| 17 | print "=== Done scanning and generating, now doing 'import sndsupport' ===" |
| 18 | import sndsupport |
| 19 | print "=== Done. It's up to you to compile Sndmodule.c ===" |
| 20 | |
| 21 | class SoundScanner(Scanner): |
| 22 | |
| 23 | def destination(self, type, name, arglist): |
| 24 | classname = "SndFunction" |
| 25 | listname = "functions" |
| 26 | if arglist: |
| 27 | t, n, m = arglist[0] |
| 28 | if t == "SndChannelPtr" and m == "InMode": |
| 29 | classname = "SndMethod" |
| 30 | listname = "sndmethods" |
| 31 | return classname, listname |
| 32 | |
| 33 | def makeblacklistnames(self): |
| 34 | return [ |
| 35 | 'SndDisposeChannel', # automatic on deallocation |
| 36 | 'SndAddModifier', # for internal use only |
| 37 | 'SndPlayDoubleBuffer', # very low level routine |
| 38 | # Obsolete: |
| 39 | 'StartSound', |
| 40 | 'StopSound', |
| 41 | 'SoundDone', |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 42 | # These are soundMgr 3.0 routines that I can't seem to find... |
| 43 | 'GetSoundPreference', |
| 44 | 'SetSoundPreference', |
| 45 | 'GetCompressionInfo', |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 46 | |
| 47 | ] |
| 48 | |
| 49 | def makeblacklisttypes(self): |
| 50 | return [ |
Guido van Rossum | 9784295 | 1995-02-19 15:59:49 +0000 | [diff] [blame] | 51 | "GetSoundVol", |
| 52 | "SetSoundVol", |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 53 | "UnsignedFixed", |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 54 | ] |
| 55 | |
| 56 | def makerepairinstructions(self): |
| 57 | return [ |
| 58 | ([("Str255", "*", "InMode")], |
| 59 | [("*", "*", "OutMode")]), |
| 60 | |
| 61 | ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], |
| 62 | [("InBuffer", "*", "*")]), |
| 63 | |
| 64 | ([("void", "*", "OutMode"), ("long", "*", "InMode"), |
| 65 | ("long", "*", "OutMode")], |
| 66 | [("VarVarOutBuffer", "*", "InOutMode")]), |
| 67 | |
| 68 | ([("SCStatusPtr", "*", "InMode")], |
| 69 | [("SCStatus", "*", "OutMode")]), |
| 70 | |
| 71 | ([("SMStatusPtr", "*", "InMode")], |
| 72 | [("SMStatus", "*", "OutMode")]), |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 73 | |
| 74 | ([("CompressionInfoPtr", "*", "InMode")], |
| 75 | [("CompressionInfo", "*", "OutMode")]), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 76 | |
| 77 | # For SndPlay's SndListHandle argument |
| 78 | ([("Handle", "sndHdl", "InMode")], |
| 79 | [("SndListHandle", "*", "*")]), |
| 80 | |
| 81 | # For SndStartFilePlay |
| 82 | ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")], |
| 83 | [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]), |
| 84 | |
| 85 | # For Comp3to1 etc. |
| 86 | ([("void_ptr", "inBuffer", "InMode"), |
| 87 | ("void", "outBuffer", "OutMode"), |
| 88 | ("unsigned_long", "cnt", "InMode")], |
| 89 | [("InOutBuffer", "buffer", "InOutMode")]), |
| 90 | |
| 91 | # Ditto |
| 92 | ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")], |
| 93 | [("InOutBuf128", "state", "InOutMode")]), |
| 94 | ] |
| 95 | |
| 96 | if __name__ == "__main__": |
| 97 | main() |