blob: 7504aefd93bf36e04e8c6f3cf36406dd738a7015 [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
Jack Jansenaaebdd62002-08-05 15:39:30 +00006from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00007sys.path.append(BGENDIR)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00008
Guido van Rossum17448e21995-01-30 11:53:55 +00009from scantools import Scanner
10
11def main():
Tim Peters182b5ac2004-07-18 06:16:08 +000012 input = "Sound.h"
13 output = "sndgen.py"
14 defsoutput = TOOLBOXDIR + "Sound.py"
15 scanner = SoundScanner(input, output, defsoutput)
16 scanner.scan()
17 scanner.close()
18 print "=== Testing definitions output code ==="
19 execfile(defsoutput, {}, {})
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 ==="
Guido van Rossum17448e21995-01-30 11:53:55 +000023
24class SoundScanner(Scanner):
25
Tim Peters182b5ac2004-07-18 06:16:08 +000026 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
Guido van Rossum17448e21995-01-30 11:53:55 +000035
Tim Peters182b5ac2004-07-18 06:16:08 +000036 def writeinitialdefs(self):
37 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansen21f96871998-02-20 16:02:09 +000038
Tim Peters182b5ac2004-07-18 06:16:08 +000039 def makeblacklistnames(self):
40 return [
41 'SndDisposeChannel', # automatic on deallocation
42 'SndAddModifier', # for internal use only
43 'SndPlayDoubleBuffer', # very low level routine
44 # Missing from libraries (UH332)
45 'SoundManagerSetInfo',
46 'SoundManagerGetInfo',
47 # Constants with funny definitions
48 'rate48khz',
49 'rate44khz',
50 'kInvalidSource',
51 # OS8 only:
52 'MACEVersion',
53 'SPBRecordToFile',
54 'Exp1to6',
55 'Comp6to1',
56 'Exp1to3',
57 'Comp3to1',
58 'SndControl',
59 'SndStopFilePlay',
60 'SndStartFilePlay',
61 'SndPauseFilePlay',
62 'SndRecordToFile',
Guido van Rossum17448e21995-01-30 11:53:55 +000063
Tim Peters182b5ac2004-07-18 06:16:08 +000064 ]
Guido van Rossum17448e21995-01-30 11:53:55 +000065
Tim Peters182b5ac2004-07-18 06:16:08 +000066 def makeblacklisttypes(self):
67 return [
68 "GetSoundVol",
69 "SetSoundVol",
70 "UnsignedFixed",
71 # Don't have the time to dig into this...
72 "Component",
73 "ComponentInstance",
74 "SoundComponentDataPtr",
75 "SoundComponentData",
76 "SoundComponentData_ptr",
77 "SoundConverter",
78 ]
Guido van Rossum17448e21995-01-30 11:53:55 +000079
Tim Peters182b5ac2004-07-18 06:16:08 +000080 def makerepairinstructions(self):
81 return [
82 ([("Str255", "*", "InMode")],
83 [("*", "*", "OutMode")]),
Jack Jansen7d0bc831995-06-09 20:56:31 +000084
Tim Peters182b5ac2004-07-18 06:16:08 +000085 ([("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")]),
97
98 ([("CompressionInfoPtr", "*", "InMode")],
99 [("CompressionInfo", "*", "OutMode")]),
100
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
116## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
117## [("InOutBuf128", "state", "InOutMode")]),
118 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
119 [("StateBlock", "state", "InOutMode")]),
120
121 # Catch-all for the last couple of void pointers
122 ([("void", "*", "OutMode")],
123 [("void_ptr", "*", "InMode")]),
124 ]
Guido van Rossum17448e21995-01-30 11:53:55 +0000125
126if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +0000127 main()