Ditched '_find_SET()', since it was a no-value-added wrapper around
[python/dscho.git] / Mac / Modules / snd / sndscan.py
bloba190bfe1bbaa2c3ea4fde80c460e28d4dff51d7e
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 sys
6 import os
7 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
8 sys.path.append(BGENDIR)
9 from bgenlocations import TOOLBOXDIR
11 from scantools import Scanner
13 def main():
14 input = "Sound.h"
15 output = "sndgen.py"
16 defsoutput = TOOLBOXDIR + "Sound.py"
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 ==="
24 class SoundScanner(Scanner):
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
36 def writeinitialdefs(self):
37 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
39 def makeblacklistnames(self):
40 return [
41 'SndDisposeChannel', # automatic on deallocation
42 'SndAddModifier', # for internal use only
43 'SndPlayDoubleBuffer', # very low level routine
44 # Obsolete:
45 'StartSound',
46 'StopSound',
47 'SoundDone',
48 # These do not work for cfm68k:
49 ## 'SndGetInfo',
50 ## 'SndSetInfo',
51 ## 'GetCompressionInfo',
52 ## 'GetCompressionName',
53 ## 'GetSoundPreference',
54 ## 'SetSoundPreference',
55 # And old calls that are no longer supported
56 'SetSoundVol',
57 'GetSoundVol',
58 # Constants with funny definitions
59 'rate48khz',
60 'rate44khz',
61 'kInvalidSource',
65 def makeblacklisttypes(self):
66 return [
67 "GetSoundVol",
68 "SetSoundVol",
69 "UnsignedFixed",
70 # Don't have the time to dig into this...
71 "Component",
72 "ComponentInstance",
73 "SoundComponentDataPtr",
74 "SoundComponentData",
75 "SoundComponentData_ptr",
76 "SoundConverter",
77 "ModalFilterUPP",
80 def makerepairinstructions(self):
81 return [
82 ([("Str255", "*", "InMode")],
83 [("*", "*", "OutMode")]),
85 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
86 [("InBuffer", "*", "*")]),
88 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
89 ("long", "*", "OutMode")],
90 [("VarVarOutBuffer", "*", "InOutMode")]),
92 ([("SCStatusPtr", "*", "InMode")],
93 [("SCStatus", "*", "OutMode")]),
95 ([("SMStatusPtr", "*", "InMode")],
96 [("SMStatus", "*", "OutMode")]),
98 ([("CompressionInfoPtr", "*", "InMode")],
99 [("CompressionInfo", "*", "OutMode")]),
101 # For SndPlay's SndListHandle argument
102 ([("Handle", "sndHdl", "InMode")],
103 [("SndListHandle", "*", "*")]),
105 # For SndStartFilePlay
106 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
107 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
109 # For Comp3to1 etc.
110 ([("void_ptr", "inBuffer", "InMode"),
111 ("void", "outBuffer", "OutMode"),
112 ("unsigned_long", "cnt", "InMode")],
113 [("InOutBuffer", "buffer", "InOutMode")]),
115 # Ditto
116 ## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
117 ## [("InOutBuf128", "state", "InOutMode")]),
118 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
119 [("StateBlock", "state", "InOutMode")]),
121 # Catch-all for the last couple of void pointers
122 ([("void", "*", "OutMode")],
123 [("void_ptr", "*", "InMode")]),
126 if __name__ == "__main__":
127 main()