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.)
7 from bgenlocations
import TOOLBOXDIR
, BGENDIR
8 sys
.path
.append(BGENDIR
)
10 from scantools
import Scanner
15 defsoutput
= TOOLBOXDIR
+ "Sound.py"
16 scanner
= SoundScanner(input, output
, defsoutput
)
19 print "=== Testing definitions output code ==="
20 execfile(defsoutput
, {}, {})
21 print "=== Done scanning and generating, now doing 'import sndsupport' ==="
23 print "=== Done. It's up to you to compile Sndmodule.c ==="
25 class SoundScanner(Scanner
):
27 def destination(self
, type, name
, arglist
):
28 classname
= "SndFunction"
29 listname
= "functions"
32 if t
== "SndChannelPtr" and m
== "InMode":
33 classname
= "SndMethod"
34 listname
= "sndmethods"
35 return classname
, listname
37 def writeinitialdefs(self
):
38 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
40 def makeblacklistnames(self
):
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
67 def makeblacklisttypes(self
):
72 # Don't have the time to dig into this...
75 "SoundComponentDataPtr",
77 "SoundComponentData_ptr",
81 def makerepairinstructions(self
):
83 ([("Str255", "*", "InMode")],
84 [("*", "*", "OutMode")]),
86 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
87 [("InBuffer", "*", "*")]),
89 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
90 ("long", "*", "OutMode")],
91 [("VarVarOutBuffer", "*", "InOutMode")]),
93 ([("SCStatusPtr", "*", "InMode")],
94 [("SCStatus", "*", "OutMode")]),
96 ([("SMStatusPtr", "*", "InMode")],
97 [("SMStatus", "*", "OutMode")]),
99 ([("CompressionInfoPtr", "*", "InMode")],
100 [("CompressionInfo", "*", "OutMode")]),
102 # For SndPlay's SndListHandle argument
103 ([("Handle", "sndHdl", "InMode")],
104 [("SndListHandle", "*", "*")]),
106 # For SndStartFilePlay
107 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
108 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
111 ([("void_ptr", "inBuffer", "InMode"),
112 ("void", "outBuffer", "OutMode"),
113 ("unsigned_long", "cnt", "InMode")],
114 [("InOutBuffer", "buffer", "InOutMode")]),
117 ## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
118 ## [("InOutBuf128", "state", "InOutMode")]),
119 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
120 [("StateBlock", "state", "InOutMode")]),
122 # Catch-all for the last couple of void pointers
123 ([("void", "*", "OutMode")],
124 [("void_ptr", "*", "InMode")]),
127 if __name__
== "__main__":