Oops -- Lib/Test should be Lib/test, of course!
[python/dscho.git] / Mac / Modules / snd / sndscan.py
blobc7ca36bcc3d18cc51d506578d0205999a5eb6bb5
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.)
5 import addpack
6 addpack.addpack(':Tools:bgen:bgen')
7 from bgenlocations import TOOLBOXDIR
9 from scantools import Scanner
11 def main():
12 input = "Sound.h"
13 output = "sndgen.py"
14 defsoutput = TOOLBOXDIR + "Sound.py"
15 scanner = SoundScanner(input, output, defsoutput)
16 scanner.scan()
17 scanner.close()
18 print "=== Done scanning and generating, now doing 'import sndsupport' ==="
19 import sndsupport
20 print "=== Done. It's up to you to compile Sndmodule.c ==="
22 class SoundScanner(Scanner):
24 def destination(self, type, name, arglist):
25 classname = "SndFunction"
26 listname = "functions"
27 if arglist:
28 t, n, m = arglist[0]
29 if t == "SndChannelPtr" and m == "InMode":
30 classname = "SndMethod"
31 listname = "sndmethods"
32 return classname, listname
34 def writeinitialdefs(self):
35 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
37 def makeblacklistnames(self):
38 return [
39 'SndDisposeChannel', # automatic on deallocation
40 'SndAddModifier', # for internal use only
41 'SndPlayDoubleBuffer', # very low level routine
42 # Obsolete:
43 'StartSound',
44 'StopSound',
45 'SoundDone',
46 # These do not work for cfm68k:
47 'SndGetInfo',
48 'SndSetInfo',
49 'GetCompressionInfo',
50 'GetCompressionName',
51 'GetSoundPreference',
52 'SetSoundPreference',
53 # And old calls that are no longer supported
54 'SetSoundVol',
55 'GetSoundVol',
59 def makeblacklisttypes(self):
60 return [
61 "GetSoundVol",
62 "SetSoundVol",
63 "UnsignedFixed",
64 # Don't have the time to dig into this...
65 "Component",
66 "ComponentInstance",
67 "SoundComponentDataPtr",
68 "SoundComponentData",
69 "SoundComponentData_ptr",
70 "SoundConverter",
71 "ModalFilterUPP",
74 def makerepairinstructions(self):
75 return [
76 ([("Str255", "*", "InMode")],
77 [("*", "*", "OutMode")]),
79 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
80 [("InBuffer", "*", "*")]),
82 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
83 ("long", "*", "OutMode")],
84 [("VarVarOutBuffer", "*", "InOutMode")]),
86 ([("SCStatusPtr", "*", "InMode")],
87 [("SCStatus", "*", "OutMode")]),
89 ([("SMStatusPtr", "*", "InMode")],
90 [("SMStatus", "*", "OutMode")]),
92 ([("CompressionInfoPtr", "*", "InMode")],
93 [("CompressionInfo", "*", "OutMode")]),
95 # For SndPlay's SndListHandle argument
96 ([("Handle", "sndHdl", "InMode")],
97 [("SndListHandle", "*", "*")]),
99 # For SndStartFilePlay
100 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
101 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
103 # For Comp3to1 etc.
104 ([("void_ptr", "inBuffer", "InMode"),
105 ("void", "outBuffer", "OutMode"),
106 ("unsigned_long", "cnt", "InMode")],
107 [("InOutBuffer", "buffer", "InOutMode")]),
109 # Ditto
110 ## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
111 ## [("InOutBuf128", "state", "InOutMode")]),
112 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
113 [("StateBlock", "state", "InOutMode")]),
115 # Catch-all for the last couple of void pointers
116 ([("void", "*", "OutMode")],
117 [("void_ptr", "*", "InMode")]),
120 if __name__ == "__main__":
121 main()