blob: a287c73a424f14f38e14c79827bc94302f2786ac [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',
Jack Jansen6c7e3262002-12-12 10:31:54 +000052 # OS8 only:
53 'MACEVersion',
54 'SPBRecordToFile',
55 'Exp1to6',
56 'Comp6to1',
57 'Exp1to3',
58 'Comp3to1',
59 'SndControl',
60 'SndStopFilePlay',
61 'SndStartFilePlay',
62 'SndPauseFilePlay',
63 'SndRecordToFile',
Guido van Rossum17448e21995-01-30 11:53:55 +000064
65 ]
66
67 def makeblacklisttypes(self):
68 return [
Guido van Rossum97842951995-02-19 15:59:49 +000069 "GetSoundVol",
70 "SetSoundVol",
Jack Jansenb81cf9d1995-06-06 13:08:40 +000071 "UnsignedFixed",
Jack Jansend40f3c61995-10-09 23:12:22 +000072 # Don't have the time to dig into this...
73 "Component",
Jack Jansen21f96871998-02-20 16:02:09 +000074 "ComponentInstance",
75 "SoundComponentDataPtr",
76 "SoundComponentData",
77 "SoundComponentData_ptr",
78 "SoundConverter",
Guido van Rossum17448e21995-01-30 11:53:55 +000079 ]
80
81 def makerepairinstructions(self):
82 return [
83 ([("Str255", "*", "InMode")],
84 [("*", "*", "OutMode")]),
85
86 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
87 [("InBuffer", "*", "*")]),
88
89 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
90 ("long", "*", "OutMode")],
91 [("VarVarOutBuffer", "*", "InOutMode")]),
92
93 ([("SCStatusPtr", "*", "InMode")],
94 [("SCStatus", "*", "OutMode")]),
95
96 ([("SMStatusPtr", "*", "InMode")],
97 [("SMStatus", "*", "OutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000098
99 ([("CompressionInfoPtr", "*", "InMode")],
100 [("CompressionInfo", "*", "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000101
102 # For SndPlay's SndListHandle argument
103 ([("Handle", "sndHdl", "InMode")],
104 [("SndListHandle", "*", "*")]),
105
106 # For SndStartFilePlay
107 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
108 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
109
110 # For Comp3to1 etc.
111 ([("void_ptr", "inBuffer", "InMode"),
112 ("void", "outBuffer", "OutMode"),
113 ("unsigned_long", "cnt", "InMode")],
114 [("InOutBuffer", "buffer", "InOutMode")]),
115
116 # Ditto
Jack Jansen7d0bc831995-06-09 20:56:31 +0000117## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
118## [("InOutBuf128", "state", "InOutMode")]),
119 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
120 [("StateBlock", "state", "InOutMode")]),
121
Jack Jansen52b38b71998-02-25 15:47:51 +0000122 # Catch-all for the last couple of void pointers
123 ([("void", "*", "OutMode")],
124 [("void_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000125 ]
126
127if __name__ == "__main__":
128 main()