blob: 9c1ff1053b9ae1355f28d6189fdb3c55a7f3ecd2 [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
7BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
8sys.path.append(BGENDIR)
Jack Jansen46d9e791996-04-12 16:29:23 +00009from bgenlocations import TOOLBOXDIR
Jack Jansenb81cf9d1995-06-06 13:08:40 +000010
Guido van Rossum17448e21995-01-30 11:53:55 +000011from scantools import Scanner
12
13def main():
14 input = "Sound.h"
15 output = "sndgen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000016 defsoutput = TOOLBOXDIR + "Sound.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000017 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 ==="
23
24class SoundScanner(Scanner):
25
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
35
Jack Jansen21f96871998-02-20 16:02:09 +000036 def writeinitialdefs(self):
37 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
38
Guido van Rossum17448e21995-01-30 11:53:55 +000039 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',
Jack Jansen52b38b71998-02-25 15:47:51 +000048 # These do not work for cfm68k:
Jack Jansena05ac601999-12-12 21:41:51 +000049## 'SndGetInfo',
50## 'SndSetInfo',
51## 'GetCompressionInfo',
52## 'GetCompressionName',
53## 'GetSoundPreference',
54## 'SetSoundPreference',
Jack Jansene5649c71996-08-19 10:59:44 +000055 # And old calls that are no longer supported
56 'SetSoundVol',
57 'GetSoundVol',
Jack Jansenb1b78d81999-12-14 15:47:01 +000058 # Constants with funny definitions
59 'rate48khz',
60 'rate44khz',
61 'kInvalidSource',
Guido van Rossum17448e21995-01-30 11:53:55 +000062
63 ]
64
Jack Jansen8d929ae2000-06-21 22:07:06 +000065 def makegreylist(self):
66 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000067 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansen8d929ae2000-06-21 22:07:06 +000068 'MACEVersion',
69 'SPBRecordToFile',
70 'Exp1to6',
71 'Comp6to1',
72 'Exp1to3',
73 'Comp3to1',
74 'SndControl',
75 'SndStopFilePlay',
76 'SndStartFilePlay',
77 'SndPauseFilePlay',
78 ])]
79
Guido van Rossum17448e21995-01-30 11:53:55 +000080 def makeblacklisttypes(self):
81 return [
Guido van Rossum97842951995-02-19 15:59:49 +000082 "GetSoundVol",
83 "SetSoundVol",
Jack Jansenb81cf9d1995-06-06 13:08:40 +000084 "UnsignedFixed",
Jack Jansend40f3c61995-10-09 23:12:22 +000085 # Don't have the time to dig into this...
86 "Component",
Jack Jansen21f96871998-02-20 16:02:09 +000087 "ComponentInstance",
88 "SoundComponentDataPtr",
89 "SoundComponentData",
90 "SoundComponentData_ptr",
91 "SoundConverter",
92 "ModalFilterUPP",
Guido van Rossum17448e21995-01-30 11:53:55 +000093 ]
94
95 def makerepairinstructions(self):
96 return [
97 ([("Str255", "*", "InMode")],
98 [("*", "*", "OutMode")]),
99
100 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
101 [("InBuffer", "*", "*")]),
102
103 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
104 ("long", "*", "OutMode")],
105 [("VarVarOutBuffer", "*", "InOutMode")]),
106
107 ([("SCStatusPtr", "*", "InMode")],
108 [("SCStatus", "*", "OutMode")]),
109
110 ([("SMStatusPtr", "*", "InMode")],
111 [("SMStatus", "*", "OutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000112
113 ([("CompressionInfoPtr", "*", "InMode")],
114 [("CompressionInfo", "*", "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000115
116 # For SndPlay's SndListHandle argument
117 ([("Handle", "sndHdl", "InMode")],
118 [("SndListHandle", "*", "*")]),
119
120 # For SndStartFilePlay
121 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
122 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
123
124 # For Comp3to1 etc.
125 ([("void_ptr", "inBuffer", "InMode"),
126 ("void", "outBuffer", "OutMode"),
127 ("unsigned_long", "cnt", "InMode")],
128 [("InOutBuffer", "buffer", "InOutMode")]),
129
130 # Ditto
Jack Jansen7d0bc831995-06-09 20:56:31 +0000131## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
132## [("InOutBuf128", "state", "InOutMode")]),
133 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
134 [("StateBlock", "state", "InOutMode")]),
135
Jack Jansen52b38b71998-02-25 15:47:51 +0000136 # Catch-all for the last couple of void pointers
137 ([("void", "*", "OutMode")],
138 [("void_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000139 ]
140
141if __name__ == "__main__":
142 main()