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 | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 5 | import sys |
| 6 | import os |
| 7 | BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen') |
| 8 | sys.path.append(BGENDIR) |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 9 | from bgenlocations import TOOLBOXDIR |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 10 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 11 | from scantools import Scanner |
| 12 | |
| 13 | def main(): |
| 14 | input = "Sound.h" |
| 15 | output = "sndgen.py" |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 16 | defsoutput = TOOLBOXDIR + "Sound.py" |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 17 | scanner = SoundScanner(input, output, defsoutput) |
| 18 | scanner.scan() |
| 19 | scanner.close() |
| 20 | print "=== Done scanning and generating, now doing 'import sndsupport' ===" |
| 21 | import sndsupport |
| 22 | print "=== Done. It's up to you to compile Sndmodule.c ===" |
| 23 | |
| 24 | class SoundScanner(Scanner): |
| 25 | |
| 26 | def destination(self, type, name, arglist): |
| 27 | classname = "SndFunction" |
| 28 | listname = "functions" |
| 29 | if arglist: |
| 30 | t, n, m = arglist[0] |
| 31 | if t == "SndChannelPtr" and m == "InMode": |
| 32 | classname = "SndMethod" |
| 33 | listname = "sndmethods" |
| 34 | return classname, listname |
| 35 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 36 | def writeinitialdefs(self): |
| 37 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
| 38 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 39 | def makeblacklistnames(self): |
| 40 | return [ |
| 41 | 'SndDisposeChannel', # automatic on deallocation |
| 42 | 'SndAddModifier', # for internal use only |
| 43 | 'SndPlayDoubleBuffer', # very low level routine |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 44 | # Missing from libraries (UH332) |
| 45 | 'SoundManagerSetInfo', |
| 46 | 'SoundManagerGetInfo', |
Jack Jansen | b1b78d8 | 1999-12-14 15:47:01 +0000 | [diff] [blame] | 47 | # Constants with funny definitions |
| 48 | 'rate48khz', |
| 49 | 'rate44khz', |
| 50 | 'kInvalidSource', |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 51 | |
| 52 | ] |
| 53 | |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 54 | def makegreylist(self): |
| 55 | return [ |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 56 | ('#if !TARGET_API_MAC_CARBON', [ |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 57 | 'MACEVersion', |
| 58 | 'SPBRecordToFile', |
| 59 | 'Exp1to6', |
| 60 | 'Comp6to1', |
| 61 | 'Exp1to3', |
| 62 | 'Comp3to1', |
| 63 | 'SndControl', |
| 64 | 'SndStopFilePlay', |
| 65 | 'SndStartFilePlay', |
| 66 | 'SndPauseFilePlay', |
Jack Jansen | 6a60915 | 2002-02-05 22:35:36 +0000 | [diff] [blame^] | 67 | 'SndRecordToFile', |
Jack Jansen | 8d929ae | 2000-06-21 22:07:06 +0000 | [diff] [blame] | 68 | ])] |
| 69 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 70 | def makeblacklisttypes(self): |
| 71 | return [ |
Guido van Rossum | 9784295 | 1995-02-19 15:59:49 +0000 | [diff] [blame] | 72 | "GetSoundVol", |
| 73 | "SetSoundVol", |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 74 | "UnsignedFixed", |
Jack Jansen | d40f3c6 | 1995-10-09 23:12:22 +0000 | [diff] [blame] | 75 | # Don't have the time to dig into this... |
| 76 | "Component", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 77 | "ComponentInstance", |
| 78 | "SoundComponentDataPtr", |
| 79 | "SoundComponentData", |
| 80 | "SoundComponentData_ptr", |
| 81 | "SoundConverter", |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 82 | ] |
| 83 | |
| 84 | def makerepairinstructions(self): |
| 85 | return [ |
| 86 | ([("Str255", "*", "InMode")], |
| 87 | [("*", "*", "OutMode")]), |
| 88 | |
| 89 | ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], |
| 90 | [("InBuffer", "*", "*")]), |
| 91 | |
| 92 | ([("void", "*", "OutMode"), ("long", "*", "InMode"), |
| 93 | ("long", "*", "OutMode")], |
| 94 | [("VarVarOutBuffer", "*", "InOutMode")]), |
| 95 | |
| 96 | ([("SCStatusPtr", "*", "InMode")], |
| 97 | [("SCStatus", "*", "OutMode")]), |
| 98 | |
| 99 | ([("SMStatusPtr", "*", "InMode")], |
| 100 | [("SMStatus", "*", "OutMode")]), |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 101 | |
| 102 | ([("CompressionInfoPtr", "*", "InMode")], |
| 103 | [("CompressionInfo", "*", "OutMode")]), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 104 | |
| 105 | # For SndPlay's SndListHandle argument |
| 106 | ([("Handle", "sndHdl", "InMode")], |
| 107 | [("SndListHandle", "*", "*")]), |
| 108 | |
| 109 | # For SndStartFilePlay |
| 110 | ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")], |
| 111 | [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]), |
| 112 | |
| 113 | # For Comp3to1 etc. |
| 114 | ([("void_ptr", "inBuffer", "InMode"), |
| 115 | ("void", "outBuffer", "OutMode"), |
| 116 | ("unsigned_long", "cnt", "InMode")], |
| 117 | [("InOutBuffer", "buffer", "InOutMode")]), |
| 118 | |
| 119 | # Ditto |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 120 | ## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")], |
| 121 | ## [("InOutBuf128", "state", "InOutMode")]), |
| 122 | ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")], |
| 123 | [("StateBlock", "state", "InOutMode")]), |
| 124 | |
Jack Jansen | 52b38b7 | 1998-02-25 15:47:51 +0000 | [diff] [blame] | 125 | # Catch-all for the last couple of void pointers |
| 126 | ([("void", "*", "OutMode")], |
| 127 | [("void_ptr", "*", "InMode")]), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 128 | ] |
| 129 | |
| 130 | if __name__ == "__main__": |
| 131 | main() |