blob: 1873c190dedbd1ecb91fc86597a07f04ab6bab05 [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
Jack Jansen723ad8a2000-12-12 22:10:21 +000044 # Missing from libraries (UH332)
45 'SoundManagerSetInfo',
46 'SoundManagerGetInfo',
Jack Jansenb1b78d81999-12-14 15:47:01 +000047 # Constants with funny definitions
48 'rate48khz',
49 'rate44khz',
50 'kInvalidSource',
Guido van Rossum17448e21995-01-30 11:53:55 +000051
52 ]
53
Jack Jansen8d929ae2000-06-21 22:07:06 +000054 def makegreylist(self):
55 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000056 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansen8d929ae2000-06-21 22:07:06 +000057 'MACEVersion',
58 'SPBRecordToFile',
59 'Exp1to6',
60 'Comp6to1',
61 'Exp1to3',
62 'Comp3to1',
63 'SndControl',
64 'SndStopFilePlay',
65 'SndStartFilePlay',
66 'SndPauseFilePlay',
67 ])]
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",
81 "ModalFilterUPP",
Guido van Rossum17448e21995-01-30 11:53:55 +000082 ]
83
84 def makerepairinstructions(self):
85 return [
86 ([("Str255", "*", "InMode")],
87 [("*", "*", "OutMode")]),
88
89 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
90 [("InBuffer", "*", "*")]),
91
92 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
93 ("long", "*", "OutMode")],
94 [("VarVarOutBuffer", "*", "InOutMode")]),
95
96 ([("SCStatusPtr", "*", "InMode")],
97 [("SCStatus", "*", "OutMode")]),
98
99 ([("SMStatusPtr", "*", "InMode")],
100 [("SMStatus", "*", "OutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000101
102 ([("CompressionInfoPtr", "*", "InMode")],
103 [("CompressionInfo", "*", "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000104
105 # For SndPlay's SndListHandle argument
106 ([("Handle", "sndHdl", "InMode")],
107 [("SndListHandle", "*", "*")]),
108
109 # For SndStartFilePlay
110 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
111 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
112
113 # For Comp3to1 etc.
114 ([("void_ptr", "inBuffer", "InMode"),
115 ("void", "outBuffer", "OutMode"),
116 ("unsigned_long", "cnt", "InMode")],
117 [("InOutBuffer", "buffer", "InOutMode")]),
118
119 # Ditto
Jack Jansen7d0bc831995-06-09 20:56:31 +0000120## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
121## [("InOutBuf128", "state", "InOutMode")]),
122 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
123 [("StateBlock", "state", "InOutMode")]),
124
Jack Jansen52b38b71998-02-25 15:47:51 +0000125 # Catch-all for the last couple of void pointers
126 ([("void", "*", "OutMode")],
127 [("void_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000128 ]
129
130if __name__ == "__main__":
131 main()