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