blob: ae525934ecf6b33e1bc0cf7795dade08ff039a9a [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')
7
Guido van Rossum17448e21995-01-30 11:53:55 +00008from scantools import Scanner
9
10def main():
11 input = "Sound.h"
12 output = "sndgen.py"
13 defsoutput = "Sound.py"
14 scanner = SoundScanner(input, output, defsoutput)
15 scanner.scan()
16 scanner.close()
17 print "=== Done scanning and generating, now doing 'import sndsupport' ==="
18 import sndsupport
19 print "=== Done. It's up to you to compile Sndmodule.c ==="
20
21class SoundScanner(Scanner):
22
23 def destination(self, type, name, arglist):
24 classname = "SndFunction"
25 listname = "functions"
26 if arglist:
27 t, n, m = arglist[0]
28 if t == "SndChannelPtr" and m == "InMode":
29 classname = "SndMethod"
30 listname = "sndmethods"
31 return classname, listname
32
33 def makeblacklistnames(self):
34 return [
35 'SndDisposeChannel', # automatic on deallocation
36 'SndAddModifier', # for internal use only
37 'SndPlayDoubleBuffer', # very low level routine
38 # Obsolete:
39 'StartSound',
40 'StopSound',
41 'SoundDone',
Jack Jansenb81cf9d1995-06-06 13:08:40 +000042 # These are soundMgr 3.0 routines that I can't seem to find...
43 'GetSoundPreference',
44 'SetSoundPreference',
45 'GetCompressionInfo',
Jack Jansen7d0bc831995-06-09 20:56:31 +000046 # And 3.1 calls, ditto...
47 'SndGetInfo',
48 'SndSetInfo',
Guido van Rossum17448e21995-01-30 11:53:55 +000049
50 ]
51
52 def makeblacklisttypes(self):
53 return [
Guido van Rossum97842951995-02-19 15:59:49 +000054 "GetSoundVol",
55 "SetSoundVol",
Jack Jansenb81cf9d1995-06-06 13:08:40 +000056 "UnsignedFixed",
Guido van Rossum17448e21995-01-30 11:53:55 +000057 ]
58
59 def makerepairinstructions(self):
60 return [
61 ([("Str255", "*", "InMode")],
62 [("*", "*", "OutMode")]),
63
64 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
65 [("InBuffer", "*", "*")]),
66
67 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
68 ("long", "*", "OutMode")],
69 [("VarVarOutBuffer", "*", "InOutMode")]),
70
71 ([("SCStatusPtr", "*", "InMode")],
72 [("SCStatus", "*", "OutMode")]),
73
74 ([("SMStatusPtr", "*", "InMode")],
75 [("SMStatus", "*", "OutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000076
77 ([("CompressionInfoPtr", "*", "InMode")],
78 [("CompressionInfo", "*", "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000079
80 # For SndPlay's SndListHandle argument
81 ([("Handle", "sndHdl", "InMode")],
82 [("SndListHandle", "*", "*")]),
83
84 # For SndStartFilePlay
85 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
86 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
87
88 # For Comp3to1 etc.
89 ([("void_ptr", "inBuffer", "InMode"),
90 ("void", "outBuffer", "OutMode"),
91 ("unsigned_long", "cnt", "InMode")],
92 [("InOutBuffer", "buffer", "InOutMode")]),
93
94 # Ditto
Jack Jansen7d0bc831995-06-09 20:56:31 +000095## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
96## [("InOutBuf128", "state", "InOutMode")]),
97 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
98 [("StateBlock", "state", "InOutMode")]),
99
Guido van Rossum17448e21995-01-30 11:53:55 +0000100 ]
101
102if __name__ == "__main__":
103 main()