ยปCore Development>Code coverage>Mac/Modules/snd/sndscan.py

Python code coverage for Mac/Modules/snd/sndscan.py

#countcontent
1n/a# Scan Sound.h header file, generate sndgen.py and Sound.py files.
2n/a# Then import sndsupport (which execs sndgen.py) to generate Sndmodule.c.
3n/a# (Should learn how to tell the compiler to compile it as well.)
4n/a
5n/aimport sys
6n/afrom bgenlocations import TOOLBOXDIR, BGENDIR
7n/asys.path.append(BGENDIR)
8n/a
9n/afrom scantools import Scanner
10n/a
11n/adef main():
12n/a input = "Sound.h"
13n/a output = "sndgen.py"
14n/a defsoutput = TOOLBOXDIR + "Sound.py"
15n/a scanner = SoundScanner(input, output, defsoutput)
16n/a scanner.scan()
17n/a scanner.close()
18n/a print "=== Testing definitions output code ==="
19n/a execfile(defsoutput, {}, {})
20n/a print "=== Done scanning and generating, now doing 'import sndsupport' ==="
21n/a import sndsupport
22n/a print "=== Done. It's up to you to compile Sndmodule.c ==="
23n/a
24n/aclass SoundScanner(Scanner):
25n/a
26n/a def destination(self, type, name, arglist):
27n/a classname = "SndFunction"
28n/a listname = "functions"
29n/a if arglist:
30n/a t, n, m = arglist[0]
31n/a if t == "SndChannelPtr" and m == "InMode":
32n/a classname = "SndMethod"
33n/a listname = "sndmethods"
34n/a return classname, listname
35n/a
36n/a def writeinitialdefs(self):
37n/a self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
38n/a
39n/a def makeblacklistnames(self):
40n/a return [
41n/a 'SndDisposeChannel', # automatic on deallocation
42n/a 'SndAddModifier', # for internal use only
43n/a 'SndPlayDoubleBuffer', # very low level routine
44n/a # Missing from libraries (UH332)
45n/a 'SoundManagerSetInfo',
46n/a 'SoundManagerGetInfo',
47n/a # Constants with funny definitions
48n/a 'rate48khz',
49n/a 'rate44khz',
50n/a 'kInvalidSource',
51n/a # OS8 only:
52n/a 'MACEVersion',
53n/a 'SPBRecordToFile',
54n/a 'Exp1to6',
55n/a 'Comp6to1',
56n/a 'Exp1to3',
57n/a 'Comp3to1',
58n/a 'SndControl',
59n/a 'SndStopFilePlay',
60n/a 'SndStartFilePlay',
61n/a 'SndPauseFilePlay',
62n/a 'SndRecordToFile',
63n/a
64n/a ]
65n/a
66n/a def makeblacklisttypes(self):
67n/a return [
68n/a "GetSoundVol",
69n/a "SetSoundVol",
70n/a "UnsignedFixed",
71n/a # Don't have the time to dig into this...
72n/a "Component",
73n/a "ComponentInstance",
74n/a "SoundComponentDataPtr",
75n/a "SoundComponentData",
76n/a "SoundComponentData_ptr",
77n/a "SoundConverter",
78n/a ]
79n/a
80n/a def makerepairinstructions(self):
81n/a return [
82n/a ([("Str255", "*", "InMode")],
83n/a [("*", "*", "OutMode")]),
84n/a
85n/a ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
86n/a [("InBuffer", "*", "*")]),
87n/a
88n/a ([("void", "*", "OutMode"), ("long", "*", "InMode"),
89n/a ("long", "*", "OutMode")],
90n/a [("VarVarOutBuffer", "*", "InOutMode")]),
91n/a
92n/a ([("SCStatusPtr", "*", "InMode")],
93n/a [("SCStatus", "*", "OutMode")]),
94n/a
95n/a ([("SMStatusPtr", "*", "InMode")],
96n/a [("SMStatus", "*", "OutMode")]),
97n/a
98n/a ([("CompressionInfoPtr", "*", "InMode")],
99n/a [("CompressionInfo", "*", "OutMode")]),
100n/a
101n/a # For SndPlay's SndListHandle argument
102n/a ([("Handle", "sndHdl", "InMode")],
103n/a [("SndListHandle", "*", "*")]),
104n/a
105n/a # For SndStartFilePlay
106n/a ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
107n/a [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
108n/a
109n/a # For Comp3to1 etc.
110n/a ([("void_ptr", "inBuffer", "InMode"),
111n/a ("void", "outBuffer", "OutMode"),
112n/a ("unsigned_long", "cnt", "InMode")],
113n/a [("InOutBuffer", "buffer", "InOutMode")]),
114n/a
115n/a # Ditto
116n/a## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
117n/a## [("InOutBuf128", "state", "InOutMode")]),
118n/a ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
119n/a [("StateBlock", "state", "InOutMode")]),
120n/a
121n/a # Catch-all for the last couple of void pointers
122n/a ([("void", "*", "OutMode")],
123n/a [("void_ptr", "*", "InMode")]),
124n/a ]
125n/a
126n/aif __name__ == "__main__":
127n/a main()