blob: a190bfe1bbaa2c3ea4fde80c460e28d4dff51d7e [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
65 def makeblacklisttypes(self):
66 return [
Guido van Rossum97842951995-02-19 15:59:49 +000067 "GetSoundVol",
68 "SetSoundVol",
Jack Jansenb81cf9d1995-06-06 13:08:40 +000069 "UnsignedFixed",
Jack Jansend40f3c61995-10-09 23:12:22 +000070 # Don't have the time to dig into this...
71 "Component",
Jack Jansen21f96871998-02-20 16:02:09 +000072 "ComponentInstance",
73 "SoundComponentDataPtr",
74 "SoundComponentData",
75 "SoundComponentData_ptr",
76 "SoundConverter",
77 "ModalFilterUPP",
Guido van Rossum17448e21995-01-30 11:53:55 +000078 ]
79
80 def makerepairinstructions(self):
81 return [
82 ([("Str255", "*", "InMode")],
83 [("*", "*", "OutMode")]),
84
85 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
86 [("InBuffer", "*", "*")]),
87
88 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
89 ("long", "*", "OutMode")],
90 [("VarVarOutBuffer", "*", "InOutMode")]),
91
92 ([("SCStatusPtr", "*", "InMode")],
93 [("SCStatus", "*", "OutMode")]),
94
95 ([("SMStatusPtr", "*", "InMode")],
96 [("SMStatus", "*", "OutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000097
98 ([("CompressionInfoPtr", "*", "InMode")],
99 [("CompressionInfo", "*", "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000100
101 # For SndPlay's SndListHandle argument
102 ([("Handle", "sndHdl", "InMode")],
103 [("SndListHandle", "*", "*")]),
104
105 # For SndStartFilePlay
106 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
107 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
108
109 # For Comp3to1 etc.
110 ([("void_ptr", "inBuffer", "InMode"),
111 ("void", "outBuffer", "OutMode"),
112 ("unsigned_long", "cnt", "InMode")],
113 [("InOutBuffer", "buffer", "InOutMode")]),
114
115 # Ditto
Jack Jansen7d0bc831995-06-09 20:56:31 +0000116## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
117## [("InOutBuf128", "state", "InOutMode")]),
118 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
119 [("StateBlock", "state", "InOutMode")]),
120
Jack Jansen52b38b71998-02-25 15:47:51 +0000121 # Catch-all for the last couple of void pointers
122 ([("void", "*", "OutMode")],
123 [("void_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000124 ]
125
126if __name__ == "__main__":
127 main()