blob: fc358a047afaee9cef799ed776e828cf82dee9b8 [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()
Jack Jansen87eea882002-08-15 21:48:16 +000019 print "=== Testing definitions output code ==="
20 execfile(defsoutput, {}, {})
Guido van Rossum17448e21995-01-30 11:53:55 +000021 print "=== Done scanning and generating, now doing 'import sndsupport' ==="
22 import sndsupport
23 print "=== Done. It's up to you to compile Sndmodule.c ==="
24
25class SoundScanner(Scanner):
26
27 def destination(self, type, name, arglist):
28 classname = "SndFunction"
29 listname = "functions"
30 if arglist:
31 t, n, m = arglist[0]
32 if t == "SndChannelPtr" and m == "InMode":
33 classname = "SndMethod"
34 listname = "sndmethods"
35 return classname, listname
36
Jack Jansen21f96871998-02-20 16:02:09 +000037 def writeinitialdefs(self):
38 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
39
Guido van Rossum17448e21995-01-30 11:53:55 +000040 def makeblacklistnames(self):
41 return [
42 'SndDisposeChannel', # automatic on deallocation
43 'SndAddModifier', # for internal use only
44 'SndPlayDoubleBuffer', # very low level routine
Jack Jansen723ad8a2000-12-12 22:10:21 +000045 # Missing from libraries (UH332)
46 'SoundManagerSetInfo',
47 'SoundManagerGetInfo',
Jack Jansenb1b78d81999-12-14 15:47:01 +000048 # Constants with funny definitions
49 'rate48khz',
50 'rate44khz',
51 'kInvalidSource',
Guido van Rossum17448e21995-01-30 11:53:55 +000052
53 ]
54
Jack Jansen8d929ae2000-06-21 22:07:06 +000055 def makegreylist(self):
56 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000057 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansen8d929ae2000-06-21 22:07:06 +000058 'MACEVersion',
59 'SPBRecordToFile',
60 'Exp1to6',
61 'Comp6to1',
62 'Exp1to3',
63 'Comp3to1',
64 'SndControl',
65 'SndStopFilePlay',
66 'SndStartFilePlay',
67 'SndPauseFilePlay',
Jack Jansen6a609152002-02-05 22:35:36 +000068 'SndRecordToFile',
Jack Jansen8d929ae2000-06-21 22:07:06 +000069 ])]
70
Guido van Rossum17448e21995-01-30 11:53:55 +000071 def makeblacklisttypes(self):
72 return [
Guido van Rossum97842951995-02-19 15:59:49 +000073 "GetSoundVol",
74 "SetSoundVol",
Jack Jansenb81cf9d1995-06-06 13:08:40 +000075 "UnsignedFixed",
Jack Jansend40f3c61995-10-09 23:12:22 +000076 # Don't have the time to dig into this...
77 "Component",
Jack Jansen21f96871998-02-20 16:02:09 +000078 "ComponentInstance",
79 "SoundComponentDataPtr",
80 "SoundComponentData",
81 "SoundComponentData_ptr",
82 "SoundConverter",
Guido van Rossum17448e21995-01-30 11:53:55 +000083 ]
84
85 def makerepairinstructions(self):
86 return [
87 ([("Str255", "*", "InMode")],
88 [("*", "*", "OutMode")]),
89
90 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
91 [("InBuffer", "*", "*")]),
92
93 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
94 ("long", "*", "OutMode")],
95 [("VarVarOutBuffer", "*", "InOutMode")]),
96
97 ([("SCStatusPtr", "*", "InMode")],
98 [("SCStatus", "*", "OutMode")]),
99
100 ([("SMStatusPtr", "*", "InMode")],
101 [("SMStatus", "*", "OutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000102
103 ([("CompressionInfoPtr", "*", "InMode")],
104 [("CompressionInfo", "*", "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000105
106 # For SndPlay's SndListHandle argument
107 ([("Handle", "sndHdl", "InMode")],
108 [("SndListHandle", "*", "*")]),
109
110 # For SndStartFilePlay
111 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
112 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
113
114 # For Comp3to1 etc.
115 ([("void_ptr", "inBuffer", "InMode"),
116 ("void", "outBuffer", "OutMode"),
117 ("unsigned_long", "cnt", "InMode")],
118 [("InOutBuffer", "buffer", "InOutMode")]),
119
120 # Ditto
Jack Jansen7d0bc831995-06-09 20:56:31 +0000121## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
122## [("InOutBuf128", "state", "InOutMode")]),
123 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
124 [("StateBlock", "state", "InOutMode")]),
125
Jack Jansen52b38b71998-02-25 15:47:51 +0000126 # Catch-all for the last couple of void pointers
127 ([("void", "*", "OutMode")],
128 [("void_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000129 ]
130
131if __name__ == "__main__":
132 main()