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