blob: 9cb30d15c147a31b3daca3263824fe860a190885 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001# Scan <Controls.h>, generating ctlgen.py.
Jack Jansen0c4d9471998-04-17 14:07:56 +00002import sys
Jack Jansenaaebdd62002-08-05 15:39:30 +00003from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00004sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +00005
6from scantools import Scanner
7
8def main():
Tim Peters182b5ac2004-07-18 06:16:08 +00009# input = "Controls.h" # Universal Headers < 3.3
10 input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
11 output = "ctlgen.py"
12 defsoutput = TOOLBOXDIR + "Controls.py"
13 scanner = MyScanner(input, output, defsoutput)
14 scanner.scan()
15 scanner.close()
16 print "=== Testing definitions output code ==="
17 execfile(defsoutput, {}, {})
18 print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
19 import ctlsupport
20 print "=== Done. It's up to you to compile Ctlmodule.c ==="
Guido van Rossum17448e21995-01-30 11:53:55 +000021
22class MyScanner(Scanner):
23
Tim Peters182b5ac2004-07-18 06:16:08 +000024 def destination(self, type, name, arglist):
25 classname = "Function"
26 listname = "functions"
27 if arglist:
28 t, n, m = arglist[0]
29 if t in ("ControlHandle", "ControlRef") and m == "InMode":
30 classname = "Method"
31 listname = "methods"
32 return classname, listname
Guido van Rossum17448e21995-01-30 11:53:55 +000033
Tim Peters182b5ac2004-07-18 06:16:08 +000034 def writeinitialdefs(self):
35 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
36 self.defsfile.write("from Carbon.TextEdit import *\n")
37 self.defsfile.write("from Carbon.QuickDraw import *\n")
38 self.defsfile.write("from Carbon.Dragconst import *\n")
39 self.defsfile.write("from Carbon.CarbonEvents import *\n")
40 self.defsfile.write("from Carbon.Appearance import *\n")
41 self.defsfile.write("kDataBrowserItemAnyState = -1\n")
42 self.defsfile.write("kControlBevelButtonCenterPopupGlyphTag = -1\n")
43 self.defsfile.write("kDataBrowserClientPropertyFlagsMask = 0xFF000000\n")
44 self.defsfile.write("\n")
Jack Jansen21f96871998-02-20 16:02:09 +000045
Tim Peters182b5ac2004-07-18 06:16:08 +000046 def makeblacklistnames(self):
47 return [
48 'FindControlUnderMouse', # Generated manually, returns an existing control, not a new one.
49 'DisposeControl', # Generated manually
50 'KillControls', # Implied by close of dialog
51 'SetCtlAction',
52 'TrackControl', # Generated manually
53 'HandleControlClick', # Generated manually
54 'SetControlData', # Generated manually
55 'GetControlData', # Generated manually
56 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
57 'kDataBrowserClientPropertyFlagsMask', # ditto
58 'kDataBrowserItemAnyState', # and ditto
59 # The following are unavailable for static 68k (appearance manager)
60## 'GetBevelButtonMenuValue',
61## 'SetBevelButtonMenuValue',
62## 'GetBevelButtonMenuHandle',
63## 'SetBevelButtonTransform',
64 'SetBevelButtonGraphicAlignment',
65 'SetBevelButtonTextAlignment',
66 'SetBevelButtonTextPlacement',
67## 'SetImageWellTransform',
68## 'GetTabContentRect',
69## 'SetTabEnabled',
70## 'SetDisclosureTriangleLastValue',
71## # Unavailable in CW Pro 3 libraries
72## 'SetUpControlTextColor',
73## # Unavailable in Jack's CW Pro 5.1 libraries
74## 'GetControlRegion',
75## 'RemoveControlProperty',
76## 'IsValidControlHandle',
77## 'SetControl32BitMinimum',
78## 'GetControl32BitMinimum',
79## 'SetControl32BitMaximum',
80## 'GetControl32BitMaximum',
81## 'SetControl32BitValue',
82## 'GetControl32BitValue',
83## 'SetControlViewSize',
84## 'GetControlViewSize',
85 # Generally Bad News
86 'GetControlProperty',
87 'SetControlProperty',
88 'GetControlPropertySize',
89 'SendControlMessage', # Parameter changed from long to void* from UH3.3 to UH3.4
90 'CreateTabsControl', # wrote manually
91 'GetControlAction', # too much effort for too little usefulness
Guido van Rossum17448e21995-01-30 11:53:55 +000092
Tim Peters182b5ac2004-07-18 06:16:08 +000093 # too lazy for now
94 'GetImageWellContentInfo',
95 'GetBevelButtonContentInfo',
96 # OS8 only
97 'GetAuxiliaryControlRecord',
98 'SetControlColor',
99 ]
Guido van Rossum17448e21995-01-30 11:53:55 +0000100
Tim Peters182b5ac2004-07-18 06:16:08 +0000101 def makeblacklisttypes(self):
102 return [
103 'ProcPtr',
104# 'ControlActionUPP',
105 'Ptr',
106 'ControlDefSpec', # Don't know how to do this yet
107 'ControlDefSpec_ptr', # ditto
108 'Collection', # Ditto
109 # not-yet-supported stuff in Universal Headers 3.4:
110 'ControlColorUPP',
111 'ControlKind', # XXX easy: 2-tuple containing 2 OSType's
112# 'ControlTabEntry_ptr', # XXX needed for tabs
113# 'ControlButtonContentInfoPtr',
114# 'ControlButtonContentInfo', # XXX ugh: a union
115# 'ControlButtonContentInfo_ptr', # XXX ugh: a union
116 'ListDefSpec_ptr', # XXX see _Listmodule.c, tricky but possible
117 'DataBrowserItemID_ptr', # XXX array of UInt32, for BrowserView
118 'DataBrowserItemUPP',
119 'DataBrowserItemDataRef', # XXX void *
120 'DataBrowserCallbacks', # difficult struct
121 'DataBrowserCallbacks_ptr',
122 'DataBrowserCustomCallbacks',
123 'DataBrowserCustomCallbacks_ptr',
124## 'DataBrowserTableViewColumnDesc',
125## 'DataBrowserListViewColumnDesc',
126 'CFDataRef',
127 'DataBrowserListViewHeaderDesc', # difficult struct
128 ]
Jack Jansen229c0861999-12-09 16:03:50 +0000129
Tim Peters182b5ac2004-07-18 06:16:08 +0000130 def makerepairinstructions(self):
131 return [
132 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
133 [("InBuffer", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000134
Tim Peters182b5ac2004-07-18 06:16:08 +0000135 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
136 ("long", "*", "OutMode")],
137 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000138
Tim Peters182b5ac2004-07-18 06:16:08 +0000139## # For TrackControl
140## ([("ProcPtr", "actionProc", "InMode")],
141## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
142## ([("ControlActionUPP", "actionProc", "InMode")],
143## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000144
Tim Peters182b5ac2004-07-18 06:16:08 +0000145 # For GetControlTitle
146 ([('Str255', 'title', 'InMode')],
147 [('Str255', 'title', 'OutMode')]),
Just van Rossum66d78bf2001-12-18 12:47:47 +0000148
Tim Peters182b5ac2004-07-18 06:16:08 +0000149 ([("ControlHandle", "*", "OutMode")],
150 [("ExistingControlHandle", "*", "*")]),
151 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
152 [("ExistingControlHandle", "*", "*")]),
153
154 ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
155 [("void", "*", "ReturnMode")]),
156
157 ([("DataBrowserListViewColumnDesc", "*", "OutMode")],
158 [("DataBrowserListViewColumnDesc", "*", "InMode")]),
159
160 ([("ControlButtonContentInfoPtr", 'outContent', "InMode")],
161 [("ControlButtonContentInfoPtr", '*', "OutMode")]),
162
163 ([("ControlButtonContentInfo", '*', "OutMode")],
164 [("ControlButtonContentInfo", '*', "InMode")]),
165
166 ([("ControlActionUPP", 'liveTrackingProc', "InMode")],
167 [("ControlActionUPPNewControl", 'liveTrackingProc', "InMode")]),
168 ]
Guido van Rossum17448e21995-01-30 11:53:55 +0000169
170if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +0000171 main()