Added duplicate call to fileConfig() to ensure that it cleans up after itself correctly.
[python.git] / Mac / Modules / snd / sndscan.py
blobc4a82663db56f02ccc3e090e4f1e6bf39ca9a07e
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 from bgenlocations import TOOLBOXDIR, BGENDIR
8 sys.path.append(BGENDIR)
10 from scantools import Scanner
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 ==="
25 class SoundScanner(Scanner):
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
37 def writeinitialdefs(self):
38 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
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',
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",
81 def makerepairinstructions(self):
82 return [
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")]),
110 # For Comp3to1 etc.
111 ([("void_ptr", "inBuffer", "InMode"),
112 ("void", "outBuffer", "OutMode"),
113 ("unsigned_long", "cnt", "InMode")],
114 [("InOutBuffer", "buffer", "InOutMode")]),
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")]),
122 # Catch-all for the last couple of void pointers
123 ([("void", "*", "OutMode")],
124 [("void_ptr", "*", "InMode")]),
127 if __name__ == "__main__":
128 main()