blob: c7ca36bcc3d18cc51d506578d0205999a5eb6bb5 [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 Jansenb81cf9d1995-06-06 13:08:40 +00005import addpack
6addpack.addpack(':Tools:bgen:bgen')
Jack Jansen46d9e791996-04-12 16:29:23 +00007from bgenlocations import TOOLBOXDIR
Jack Jansenb81cf9d1995-06-06 13:08:40 +00008
Guido van Rossum17448e21995-01-30 11:53:55 +00009from scantools import Scanner
10
11def main():
12 input = "Sound.h"
13 output = "sndgen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000014 defsoutput = TOOLBOXDIR + "Sound.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000015 scanner = SoundScanner(input, output, defsoutput)
16 scanner.scan()
17 scanner.close()
18 print "=== Done scanning and generating, now doing 'import sndsupport' ==="
19 import sndsupport
20 print "=== Done. It's up to you to compile Sndmodule.c ==="
21
22class SoundScanner(Scanner):
23
24 def destination(self, type, name, arglist):
25 classname = "SndFunction"
26 listname = "functions"
27 if arglist:
28 t, n, m = arglist[0]
29 if t == "SndChannelPtr" and m == "InMode":
30 classname = "SndMethod"
31 listname = "sndmethods"
32 return classname, listname
33
Jack Jansen21f96871998-02-20 16:02:09 +000034 def writeinitialdefs(self):
35 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
36
Guido van Rossum17448e21995-01-30 11:53:55 +000037 def makeblacklistnames(self):
38 return [
39 'SndDisposeChannel', # automatic on deallocation
40 'SndAddModifier', # for internal use only
41 'SndPlayDoubleBuffer', # very low level routine
42 # Obsolete:
43 'StartSound',
44 'StopSound',
45 'SoundDone',
Jack Jansen52b38b71998-02-25 15:47:51 +000046 # These do not work for cfm68k:
Jack Jansen7d0bc831995-06-09 20:56:31 +000047 'SndGetInfo',
48 'SndSetInfo',
Jack Jansen52b38b71998-02-25 15:47:51 +000049 'GetCompressionInfo',
50 'GetCompressionName',
51 'GetSoundPreference',
52 'SetSoundPreference',
Jack Jansene5649c71996-08-19 10:59:44 +000053 # And old calls that are no longer supported
54 'SetSoundVol',
55 'GetSoundVol',
Guido van Rossum17448e21995-01-30 11:53:55 +000056
57 ]
58
59 def makeblacklisttypes(self):
60 return [
Guido van Rossum97842951995-02-19 15:59:49 +000061 "GetSoundVol",
62 "SetSoundVol",
Jack Jansenb81cf9d1995-06-06 13:08:40 +000063 "UnsignedFixed",
Jack Jansend40f3c61995-10-09 23:12:22 +000064 # Don't have the time to dig into this...
65 "Component",
Jack Jansen21f96871998-02-20 16:02:09 +000066 "ComponentInstance",
67 "SoundComponentDataPtr",
68 "SoundComponentData",
69 "SoundComponentData_ptr",
70 "SoundConverter",
71 "ModalFilterUPP",
Guido van Rossum17448e21995-01-30 11:53:55 +000072 ]
73
74 def makerepairinstructions(self):
75 return [
76 ([("Str255", "*", "InMode")],
77 [("*", "*", "OutMode")]),
78
79 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
80 [("InBuffer", "*", "*")]),
81
82 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
83 ("long", "*", "OutMode")],
84 [("VarVarOutBuffer", "*", "InOutMode")]),
85
86 ([("SCStatusPtr", "*", "InMode")],
87 [("SCStatus", "*", "OutMode")]),
88
89 ([("SMStatusPtr", "*", "InMode")],
90 [("SMStatus", "*", "OutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000091
92 ([("CompressionInfoPtr", "*", "InMode")],
93 [("CompressionInfo", "*", "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000094
95 # For SndPlay's SndListHandle argument
96 ([("Handle", "sndHdl", "InMode")],
97 [("SndListHandle", "*", "*")]),
98
99 # For SndStartFilePlay
100 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
101 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
102
103 # For Comp3to1 etc.
104 ([("void_ptr", "inBuffer", "InMode"),
105 ("void", "outBuffer", "OutMode"),
106 ("unsigned_long", "cnt", "InMode")],
107 [("InOutBuffer", "buffer", "InOutMode")]),
108
109 # Ditto
Jack Jansen7d0bc831995-06-09 20:56:31 +0000110## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
111## [("InOutBuf128", "state", "InOutMode")]),
112 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
113 [("StateBlock", "state", "InOutMode")]),
114
Jack Jansen52b38b71998-02-25 15:47:51 +0000115 # Catch-all for the last couple of void pointers
116 ([("void", "*", "OutMode")],
117 [("void_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000118 ]
119
120if __name__ == "__main__":
121 main()