blob: fc665bb4bcda094cde5d74c16f9bb34d758a1285 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001# 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.)
4
Jack Jansen0c4d9471998-04-17 14:07:56 +00005import sys
6import os
Jack Jansenaaebdd62002-08-05 15:39:30 +00007from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00008sys.path.append(BGENDIR)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00009
Guido van Rossum17448e21995-01-30 11:53:55 +000010from scantools import Scanner
11
12def main():
13 input = "Sound.h"
14 output = "sndgen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000015 defsoutput = TOOLBOXDIR + "Sound.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000016 scanner = SoundScanner(input, output, defsoutput)
17 scanner.scan()
18 scanner.close()
19 print "=== Done scanning and generating, now doing 'import sndsupport' ==="
20 import sndsupport
21 print "=== Done. It's up to you to compile Sndmodule.c ==="
22
23class SoundScanner(Scanner):
24
25 def destination(self, type, name, arglist):
26 classname = "SndFunction"
27 listname = "functions"
28 if arglist:
29 t, n, m = arglist[0]
30 if t == "SndChannelPtr" and m == "InMode":
31 classname = "SndMethod"
32 listname = "sndmethods"
33 return classname, listname
34
Jack Jansen21f96871998-02-20 16:02:09 +000035 def writeinitialdefs(self):
36 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
37
Guido van Rossum17448e21995-01-30 11:53:55 +000038 def makeblacklistnames(self):
39 return [
40 'SndDisposeChannel', # automatic on deallocation
41 'SndAddModifier', # for internal use only
42 'SndPlayDoubleBuffer', # very low level routine
Jack Jansen723ad8a2000-12-12 22:10:21 +000043 # Missing from libraries (UH332)
44 'SoundManagerSetInfo',
45 'SoundManagerGetInfo',
Jack Jansenb1b78d81999-12-14 15:47:01 +000046 # Constants with funny definitions
47 'rate48khz',
48 'rate44khz',
49 'kInvalidSource',
Guido van Rossum17448e21995-01-30 11:53:55 +000050
51 ]
52
Jack Jansen8d929ae2000-06-21 22:07:06 +000053 def makegreylist(self):
54 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000055 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansen8d929ae2000-06-21 22:07:06 +000056 'MACEVersion',
57 'SPBRecordToFile',
58 'Exp1to6',
59 'Comp6to1',
60 'Exp1to3',
61 'Comp3to1',
62 'SndControl',
63 'SndStopFilePlay',
64 'SndStartFilePlay',
65 'SndPauseFilePlay',
Jack Jansen6a609152002-02-05 22:35:36 +000066 'SndRecordToFile',
Jack Jansen8d929ae2000-06-21 22:07:06 +000067 ])]
68
Guido van Rossum17448e21995-01-30 11:53:55 +000069 def makeblacklisttypes(self):
70 return [
Guido van Rossum97842951995-02-19 15:59:49 +000071 "GetSoundVol",
72 "SetSoundVol",
Jack Jansenb81cf9d1995-06-06 13:08:40 +000073 "UnsignedFixed",
Jack Jansend40f3c61995-10-09 23:12:22 +000074 # Don't have the time to dig into this...
75 "Component",
Jack Jansen21f96871998-02-20 16:02:09 +000076 "ComponentInstance",
77 "SoundComponentDataPtr",
78 "SoundComponentData",
79 "SoundComponentData_ptr",
80 "SoundConverter",
Guido van Rossum17448e21995-01-30 11:53:55 +000081 ]
82
83 def makerepairinstructions(self):
84 return [
85 ([("Str255", "*", "InMode")],
86 [("*", "*", "OutMode")]),
87
88 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
89 [("InBuffer", "*", "*")]),
90
91 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
92 ("long", "*", "OutMode")],
93 [("VarVarOutBuffer", "*", "InOutMode")]),
94
95 ([("SCStatusPtr", "*", "InMode")],
96 [("SCStatus", "*", "OutMode")]),
97
98 ([("SMStatusPtr", "*", "InMode")],
99 [("SMStatus", "*", "OutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000100
101 ([("CompressionInfoPtr", "*", "InMode")],
102 [("CompressionInfo", "*", "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000103
104 # For SndPlay's SndListHandle argument
105 ([("Handle", "sndHdl", "InMode")],
106 [("SndListHandle", "*", "*")]),
107
108 # For SndStartFilePlay
109 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
110 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
111
112 # For Comp3to1 etc.
113 ([("void_ptr", "inBuffer", "InMode"),
114 ("void", "outBuffer", "OutMode"),
115 ("unsigned_long", "cnt", "InMode")],
116 [("InOutBuffer", "buffer", "InOutMode")]),
117
118 # Ditto
Jack Jansen7d0bc831995-06-09 20:56:31 +0000119## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
120## [("InOutBuf128", "state", "InOutMode")]),
121 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
122 [("StateBlock", "state", "InOutMode")]),
123
Jack Jansen52b38b71998-02-25 15:47:51 +0000124 # Catch-all for the last couple of void pointers
125 ([("void", "*", "OutMode")],
126 [("void_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000127 ]
128
129if __name__ == "__main__":
130 main()