blob: f2f19ecf48f6369b7a2b6a01900a1677e4bfe519 [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
7BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
8sys.path.append(BGENDIR)
Jack Jansen46d9e791996-04-12 16:29:23 +00009from bgenlocations import TOOLBOXDIR
Jack Jansenb81cf9d1995-06-06 13:08:40 +000010
Guido van Rossum17448e21995-01-30 11:53:55 +000011from scantools import Scanner
12
13def main():
14 input = "Sound.h"
15 output = "sndgen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000016 defsoutput = TOOLBOXDIR + "Sound.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000017 scanner = SoundScanner(input, output, defsoutput)
18 scanner.scan()
19 scanner.close()
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 ==="
23
24class SoundScanner(Scanner):
25
26 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
35
Jack Jansen21f96871998-02-20 16:02:09 +000036 def writeinitialdefs(self):
37 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
38
Guido van Rossum17448e21995-01-30 11:53:55 +000039 def makeblacklistnames(self):
40 return [
41 'SndDisposeChannel', # automatic on deallocation
42 'SndAddModifier', # for internal use only
43 'SndPlayDoubleBuffer', # very low level routine
44 # Obsolete:
45 'StartSound',
46 'StopSound',
47 'SoundDone',
Jack Jansen52b38b71998-02-25 15:47:51 +000048 # These do not work for cfm68k:
Jack Jansen7d0bc831995-06-09 20:56:31 +000049 'SndGetInfo',
50 'SndSetInfo',
Jack Jansen52b38b71998-02-25 15:47:51 +000051 'GetCompressionInfo',
52 'GetCompressionName',
53 'GetSoundPreference',
54 'SetSoundPreference',
Jack Jansene5649c71996-08-19 10:59:44 +000055 # And old calls that are no longer supported
56 'SetSoundVol',
57 'GetSoundVol',
Guido van Rossum17448e21995-01-30 11:53:55 +000058
59 ]
60
61 def makeblacklisttypes(self):
62 return [
Guido van Rossum97842951995-02-19 15:59:49 +000063 "GetSoundVol",
64 "SetSoundVol",
Jack Jansenb81cf9d1995-06-06 13:08:40 +000065 "UnsignedFixed",
Jack Jansend40f3c61995-10-09 23:12:22 +000066 # Don't have the time to dig into this...
67 "Component",
Jack Jansen21f96871998-02-20 16:02:09 +000068 "ComponentInstance",
69 "SoundComponentDataPtr",
70 "SoundComponentData",
71 "SoundComponentData_ptr",
72 "SoundConverter",
73 "ModalFilterUPP",
Guido van Rossum17448e21995-01-30 11:53:55 +000074 ]
75
76 def makerepairinstructions(self):
77 return [
78 ([("Str255", "*", "InMode")],
79 [("*", "*", "OutMode")]),
80
81 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
82 [("InBuffer", "*", "*")]),
83
84 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
85 ("long", "*", "OutMode")],
86 [("VarVarOutBuffer", "*", "InOutMode")]),
87
88 ([("SCStatusPtr", "*", "InMode")],
89 [("SCStatus", "*", "OutMode")]),
90
91 ([("SMStatusPtr", "*", "InMode")],
92 [("SMStatus", "*", "OutMode")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000093
94 ([("CompressionInfoPtr", "*", "InMode")],
95 [("CompressionInfo", "*", "OutMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000096
97 # For SndPlay's SndListHandle argument
98 ([("Handle", "sndHdl", "InMode")],
99 [("SndListHandle", "*", "*")]),
100
101 # For SndStartFilePlay
102 ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
103 [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
104
105 # For Comp3to1 etc.
106 ([("void_ptr", "inBuffer", "InMode"),
107 ("void", "outBuffer", "OutMode"),
108 ("unsigned_long", "cnt", "InMode")],
109 [("InOutBuffer", "buffer", "InOutMode")]),
110
111 # Ditto
Jack Jansen7d0bc831995-06-09 20:56:31 +0000112## ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
113## [("InOutBuf128", "state", "InOutMode")]),
114 ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
115 [("StateBlock", "state", "InOutMode")]),
116
Jack Jansen52b38b71998-02-25 15:47:51 +0000117 # Catch-all for the last couple of void pointers
118 ([("void", "*", "OutMode")],
119 [("void_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000120 ]
121
122if __name__ == "__main__":
123 main()