py-cvs-rel2_1 (Rev 1.2) merge
[python/dscho.git] / Mac / Modules / snd / sndscan.py
blob1873c190dedbd1ecb91fc86597a07f04ab6bab05
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 # Missing from libraries (UH332)
45 'SoundManagerSetInfo',
46 'SoundManagerGetInfo',
47 # Constants with funny definitions
48 'rate48khz',
49 'rate44khz',
50 'kInvalidSource',
54 def makegreylist(self):
55 return [
56 ('#if !TARGET_API_MAC_CARBON', [
57 'MACEVersion',
58 'SPBRecordToFile',
59 'Exp1to6',
60 'Comp6to1',
61 'Exp1to3',
62 'Comp3to1',
63 'SndControl',
64 'SndStopFilePlay',
65 'SndStartFilePlay',
66 'SndPauseFilePlay',
67 ])]
69 def makeblacklisttypes(self):
70 return [
71 "GetSoundVol",
72 "SetSoundVol",
73 "UnsignedFixed",
74 # Don't have the time to dig into this...
75 "Component",
76 "ComponentInstance",
77 "SoundComponentDataPtr",
78 "SoundComponentData",
79 "SoundComponentData_ptr",
80 "SoundConverter",
81 "ModalFilterUPP",
84 def makerepairinstructions(self):
85 return [
86 ([("Str255", "*", "InMode")],
87 [("*", "*", "OutMode")]),
89 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
90 [("InBuffer", "*", "*")]),
92 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
93 ("long", "*", "OutMode")],
94 [("VarVarOutBuffer", "*", "InOutMode")]),
96 ([("SCStatusPtr", "*", "InMode")],
97 [("SCStatus", "*", "OutMode")]),
99 ([("SMStatusPtr", "*", "InMode")],
100 [("SMStatus", "*", "OutMode")]),
102 ([("CompressionInfoPtr", "*", "InMode")],
103 [("CompressionInfo", "*", "OutMode")]),
105 # For SndPlay's SndListHandle argument
106 ([("Handle", "sndHdl", "InMode")],
107 [("SndListHandle", "*", "*")]),
109 # For SndStartFilePlay
110 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
111 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
113 # For Comp3to1 etc.
114 ([("void_ptr", "inBuffer", "InMode"),
115 ("void", "outBuffer", "OutMode"),
116 ("unsigned_long", "cnt", "InMode")],
117 [("InOutBuffer", "buffer", "InOutMode")]),
119 # Ditto
120 ## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
121 ## [("InOutBuf128", "state", "InOutMode")]),
122 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
123 [("StateBlock", "state", "InOutMode")]),
125 # Catch-all for the last couple of void pointers
126 ([("void", "*", "OutMode")],
127 [("void_ptr", "*", "InMode")]),
130 if __name__ == "__main__":
131 main()