home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Python 1.4 / Python 1.4 source / Mac / Modules / snd / sndscan.py < prev    next >
Encoding:
Python Source  |  1996-08-12  |  3.0 KB  |  110 lines  |  [TEXT/Pyth]

  1. # 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.  
  5. import addpack
  6. addpack.addpack(':Tools:bgen:bgen')
  7. from bgenlocations import TOOLBOXDIR
  8.  
  9. from scantools import Scanner
  10.  
  11. def main():
  12.     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 "=== Done scanning and generating, now doing 'import sndsupport' ==="
  19.     import sndsupport
  20.     print "=== Done.  It's up to you to compile Sndmodule.c ==="
  21.  
  22. class 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.  
  34.     def makeblacklistnames(self):
  35.         return [
  36.             'SndDisposeChannel',        # automatic on deallocation
  37.             'SndAddModifier',        # for internal use only
  38.             'SndPlayDoubleBuffer',        # very low level routine
  39.             # Obsolete:
  40.             'StartSound',
  41.             'StopSound',
  42.             'SoundDone',
  43.             # These are soundMgr 3.0 routines that I can't seem to find...
  44.             'GetSoundPreference',
  45.             'SetSoundPreference',
  46.             'GetCompressionInfo',
  47.             # Calls with void_ptr arguments (to be done).
  48.             'SndGetInfo',
  49.             'SndSetInfo',
  50.             # And old calls that are no longer supported
  51.             'SetSoundVol',
  52.             'GetSoundVol',
  53.  
  54.             ]
  55.  
  56.     def makeblacklisttypes(self):
  57.         return [
  58.             "GetSoundVol",
  59.             "SetSoundVol",
  60.             "UnsignedFixed",
  61.             # Don't have the time to dig into this...
  62.             "Component",
  63.             ]
  64.  
  65.     def makerepairinstructions(self):
  66.         return [
  67.             ([("Str255", "*", "InMode")],
  68.              [("*", "*", "OutMode")]),
  69.             
  70.             ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
  71.              [("InBuffer", "*", "*")]),
  72.             
  73.             ([("void", "*", "OutMode"), ("long", "*", "InMode"),
  74.                                         ("long", "*", "OutMode")],
  75.              [("VarVarOutBuffer", "*", "InOutMode")]),
  76.             
  77.             ([("SCStatusPtr", "*", "InMode")],
  78.              [("SCStatus", "*", "OutMode")]),
  79.             
  80.             ([("SMStatusPtr", "*", "InMode")],
  81.              [("SMStatus", "*", "OutMode")]),
  82.              
  83.             ([("CompressionInfoPtr", "*", "InMode")],
  84.              [("CompressionInfo", "*", "OutMode")]),
  85.             
  86.             # For SndPlay's SndListHandle argument
  87.             ([("Handle", "sndHdl", "InMode")],
  88.              [("SndListHandle", "*", "*")]),
  89.              
  90.             # For SndStartFilePlay
  91.             ([("long", "bufferSize", "InMode"), ("void", "theBuffer", "OutMode")],
  92.              [("*", "*", "*"), ("FakeType('0')", "*", "InMode")]),
  93.             
  94.             # For Comp3to1 etc.
  95.             ([("void_ptr", "inBuffer", "InMode"),
  96.               ("void", "outBuffer", "OutMode"),
  97.               ("unsigned_long", "cnt", "InMode")],
  98.              [("InOutBuffer", "buffer", "InOutMode")]),
  99.             
  100.             # Ditto
  101. ##            ([("void_ptr", "inState", "InMode"), ("void", "outState", "OutMode")],
  102. ##             [("InOutBuf128", "state", "InOutMode")]),
  103.             ([("StateBlockPtr", "inState", "InMode"), ("StateBlockPtr", "outState", "InMode")],
  104.              [("StateBlock", "state", "InOutMode")]),
  105.  
  106.             ]
  107.  
  108. if __name__ == "__main__":
  109.     main()
  110.