blob: 311295bdec389169faefbf5ee8ac8eac9fcb95b5 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001# Scan <Controls.h>, generating ctlgen.py.
Jack Jansenae8a68f1995-06-06 12:55:40 +00002import addpack
3addpack.addpack(':Tools:bgen:bgen')
Guido van Rossum17448e21995-01-30 11:53:55 +00004
5from scantools import Scanner
Jack Jansenc574b431996-04-12 16:26:59 +00006from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +00007
8def main():
9 input = "Controls.h"
10 output = "ctlgen.py"
Jack Jansenc574b431996-04-12 16:26:59 +000011 defsoutput = TOOLBOXDIR + "Controls.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000012 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
19class 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 Jansenae8a68f1995-06-06 12:55:40 +000026 if t in ("ControlHandle", "ControlRef") and m == "InMode":
Guido van Rossum17448e21995-01-30 11:53:55 +000027 classname = "Method"
28 listname = "methods"
29 return classname, listname
30
Jack Jansen21f96871998-02-20 16:02:09 +000031 def writeinitialdefs(self):
32 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
33 self.defsfile.write("from TextEdit import *\n")
34 self.defsfile.write("from QuickDraw import *\n")
35 self.defsfile.write("\n")
36
Guido van Rossum17448e21995-01-30 11:53:55 +000037 def makeblacklistnames(self):
38 return [
Jack Jansencfb60ee1996-10-01 10:46:46 +000039 'DisposeControl', # Generated manually
Guido van Rossum17448e21995-01-30 11:53:55 +000040 'KillControls', # Implied by close of dialog
41 'SetCtlAction',
Jack Jansen21f96871998-02-20 16:02:09 +000042 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
43 'kControlProgressBarIndeterminateTag', # ditto
44 # The following are unavailable for static 68k (appearance manager)
45 'GetBevelButtonMenuValue',
46 'SetBevelButtonMenuValue',
47 'GetBevelButtonMenuHandle',
48 'SetBevelButtonTransform',
49 'SetBevelButtonGraphicAlignment',
50 'SetBevelButtonTextAlignment',
51 'SetBevelButtonTextPlacement',
52 'SetImageWellTransform',
53 'GetTabContentRect',
54 'SetTabEnabled',
55 'SetDisclosureTriangleLastValue',
Guido van Rossum17448e21995-01-30 11:53:55 +000056 ]
57
58 def makeblacklisttypes(self):
59 return [
60 'ProcPtr',
Jack Jansenae8a68f1995-06-06 12:55:40 +000061 'ControlActionUPP',
Jack Jansen21f96871998-02-20 16:02:09 +000062 'ControlButtonContentInfoPtr',
63 'Ptr',
Guido van Rossum17448e21995-01-30 11:53:55 +000064 ]
65
66 def makerepairinstructions(self):
67 return [
68 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
69 [("InBuffer", "*", "*")]),
70
71 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
72 ("long", "*", "OutMode")],
73 [("VarVarOutBuffer", "*", "InOutMode")]),
74
75 # For TrackControl
76 ([("ProcPtr", "actionProc", "InMode")],
77 [("FakeType('(ControlActionUPP)0')", "*", "*")]),
Jack Jansenae8a68f1995-06-06 12:55:40 +000078 ([("ControlActionUPP", "actionProc", "InMode")],
79 [("FakeType('(ControlActionUPP)0')", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000080
81 ([("ControlHandle", "*", "OutMode")],
82 [("ExistingControlHandle", "*", "*")]),
Jack Jansenae8a68f1995-06-06 12:55:40 +000083 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
84 [("ExistingControlHandle", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000085 ]
86
87if __name__ == "__main__":
88 main()