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