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 / ic / icscan.py next >
Encoding:
Python Source  |  1996-08-02  |  1.9 KB  |  71 lines  |  [TEXT/Pyth]

  1. # Scan <Controls.h>, generating ctlgen.py.
  2. import addpack
  3. addpack.addpack(':Tools:bgen:bgen')
  4.  
  5. from scantools import Scanner
  6. from bgenlocations import TOOLBOXDIR
  7.  
  8. ICDIR=":::::Waste 1.2a5:ICProgKit 1.2"
  9.  
  10. def main():
  11.     input = ICDIR + "APIs:
  12.     output = "ctlgen.py"
  13.     defsoutput = TOOLBOXDIR + "Controls.py"
  14.     scanner = MyScanner(input, output, defsoutput)
  15.     scanner.scan()
  16.     scanner.close()
  17.     print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
  18.     import ctlsupport
  19.     print "=== Done.  It's up to you to compile Ctlmodule.c ==="
  20.  
  21. class MyScanner(Scanner):
  22.  
  23.     def destination(self, type, name, arglist):
  24.         classname = "Function"
  25.         listname = "functions"
  26.         if arglist:
  27.             t, n, m = arglist[0]
  28.             if t in ("ControlHandle", "ControlRef") and m == "InMode":
  29.                 classname = "Method"
  30.                 listname = "methods"
  31.         return classname, listname
  32.  
  33.     def makeblacklistnames(self):
  34.         return [
  35.             'DisposeControl' # Implied by deletion of control object
  36.             'KillControls', # Implied by close of dialog
  37.             'SetCtlAction',
  38.             ]
  39.  
  40.     def makeblacklisttypes(self):
  41.         return [
  42.             'ProcPtr',
  43.             'ControlActionUPP',
  44.             'CCTabHandle',
  45.             'AuxCtlHandle',
  46.             ]
  47.  
  48.     def makerepairinstructions(self):
  49.         return [
  50.             ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
  51.              [("InBuffer", "*", "*")]),
  52.             
  53.             ([("void", "*", "OutMode"), ("long", "*", "InMode"),
  54.                                         ("long", "*", "OutMode")],
  55.              [("VarVarOutBuffer", "*", "InOutMode")]),
  56.             
  57.             # For TrackControl
  58.             ([("ProcPtr", "actionProc", "InMode")],
  59.              [("FakeType('(ControlActionUPP)0')", "*", "*")]),
  60.             ([("ControlActionUPP", "actionProc", "InMode")],
  61.              [("FakeType('(ControlActionUPP)0')", "*", "*")]),
  62.             
  63.             ([("ControlHandle", "*", "OutMode")],
  64.              [("ExistingControlHandle", "*", "*")]),
  65.             ([("ControlRef", "*", "OutMode")],    # Ditto, for Universal Headers
  66.              [("ExistingControlHandle", "*", "*")]),
  67.             ]
  68.  
  69. if __name__ == "__main__":
  70.     main()
  71.