blob: f7bd888761af0bebe6cab09c240cca3e4971d016 [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():
Jack Jansenf7d5aa62000-12-10 23:43:49 +000010# input = "Controls.h" # Universal Headers < 3.3
11 input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
Guido van Rossum17448e21995-01-30 11:53:55 +000012 output = "ctlgen.py"
Jack Jansenc574b431996-04-12 16:26:59 +000013 defsoutput = TOOLBOXDIR + "Controls.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000014 scanner = MyScanner(input, output, defsoutput)
15 scanner.scan()
16 scanner.close()
Jack Jansen87eea882002-08-15 21:48:16 +000017 print "=== Testing definitions output code ==="
18 execfile(defsoutput, {}, {})
Guido van Rossum17448e21995-01-30 11:53:55 +000019 print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
20 import ctlsupport
21 print "=== Done. It's up to you to compile Ctlmodule.c ==="
22
23class MyScanner(Scanner):
24
25 def destination(self, type, name, arglist):
26 classname = "Function"
27 listname = "functions"
28 if arglist:
29 t, n, m = arglist[0]
Jack Jansenae8a68f1995-06-06 12:55:40 +000030 if t in ("ControlHandle", "ControlRef") and m == "InMode":
Guido van Rossum17448e21995-01-30 11:53:55 +000031 classname = "Method"
32 listname = "methods"
33 return classname, listname
34
Jack Jansen21f96871998-02-20 16:02:09 +000035 def writeinitialdefs(self):
36 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansen7ca993e2002-08-15 22:05:58 +000037 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")
Just van Rossume0b9fdc2001-12-12 22:40:27 +000042 self.defsfile.write("kDataBrowserItemAnyState = -1\n")
43 self.defsfile.write("kControlBevelButtonCenterPopupGlyphTag = -1\n")
Jack Jansen7ca993e2002-08-15 22:05:58 +000044 self.defsfile.write("kDataBrowserClientPropertyFlagsMask = 0xFF000000\n")
Jack Jansen21f96871998-02-20 16:02:09 +000045 self.defsfile.write("\n")
46
Guido van Rossum17448e21995-01-30 11:53:55 +000047 def makeblacklistnames(self):
48 return [
Just van Rossum7ec1c852001-12-13 21:24:37 +000049 'FindControlUnderMouse', # Generated manually, returns an existing control, not a new one.
Jack Jansencfb60ee1996-10-01 10:46:46 +000050 'DisposeControl', # Generated manually
Guido van Rossum17448e21995-01-30 11:53:55 +000051 'KillControls', # Implied by close of dialog
52 'SetCtlAction',
Jack Jansen848250c1998-05-28 14:20:09 +000053 'TrackControl', # Generated manually
Jack Jansen229c0861999-12-09 16:03:50 +000054 'HandleControlClick', # Generated manually
55 'SetControlData', # Generated manually
56 'GetControlData', # Generated manually
Jack Jansen21f96871998-02-20 16:02:09 +000057 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
Just van Rossume0b9fdc2001-12-12 22:40:27 +000058 'kDataBrowserClientPropertyFlagsMask', # ditto
59 'kDataBrowserItemAnyState', # and ditto
Jack Jansen21f96871998-02-20 16:02:09 +000060 # The following are unavailable for static 68k (appearance manager)
Jack Jansene79dc762000-06-02 21:35:07 +000061## 'GetBevelButtonMenuValue',
62## 'SetBevelButtonMenuValue',
63## 'GetBevelButtonMenuHandle',
64## 'SetBevelButtonTransform',
Jack Jansen21f96871998-02-20 16:02:09 +000065 'SetBevelButtonGraphicAlignment',
66 'SetBevelButtonTextAlignment',
67 'SetBevelButtonTextPlacement',
Jack Jansene79dc762000-06-02 21:35:07 +000068## 'SetImageWellTransform',
69## 'GetTabContentRect',
70## 'SetTabEnabled',
71## 'SetDisclosureTriangleLastValue',
Jack Jansena05ac601999-12-12 21:41:51 +000072## # 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',
Jack Jansen229c0861999-12-09 16:03:50 +000086 # Generally Bad News
87 'GetControlProperty',
88 'SetControlProperty',
89 'GetControlPropertySize',
Jack Jansenb8248d82001-06-20 21:31:28 +000090 'SendControlMessage', # Parameter changed from long to void* from UH3.3 to UH3.4
Just van Rossum66d78bf2001-12-18 12:47:47 +000091 'CreateTabsControl', # wrote manually
Just van Rossumcae6da62001-12-30 21:25:26 +000092 'GetControlAction', # too much effort for too little usefulness
Just van Rossum66d78bf2001-12-18 12:47:47 +000093
94 # too lazy for now
95 'GetImageWellContentInfo',
96 'GetBevelButtonContentInfo',
Jack Jansen6c7e3262002-12-12 10:31:54 +000097 # OS8 only
98 'GetAuxiliaryControlRecord',
99 'SetControlColor',
Guido van Rossum17448e21995-01-30 11:53:55 +0000100 ]
101
Jack Jansene79dc762000-06-02 21:35:07 +0000102 def makegreylist(self):
103 return [
Just van Rossum7eb48e32001-12-18 20:15:27 +0000104 ('#if TARGET_API_MAC_OSX', [
105 'CreateRoundButtonControl',
106 'CreateDisclosureButtonControl',
107 'CreateRelevanceBarControl',
108 'DisableControl',
109 'EnableControl',
110 'IsControlEnabled',
111 'CreateEditUnicodeTextControl',
112 'CopyDataBrowserEditText',
113 ]),
114 ]
Jack Jansene79dc762000-06-02 21:35:07 +0000115
Guido van Rossum17448e21995-01-30 11:53:55 +0000116 def makeblacklisttypes(self):
117 return [
118 'ProcPtr',
Just van Rossumcae6da62001-12-30 21:25:26 +0000119# 'ControlActionUPP',
Jack Jansen21f96871998-02-20 16:02:09 +0000120 'Ptr',
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000121 'ControlDefSpec', # Don't know how to do this yet
122 'ControlDefSpec_ptr', # ditto
123 'Collection', # Ditto
Just van Rossume0b9fdc2001-12-12 22:40:27 +0000124 # not-yet-supported stuff in Universal Headers 3.4:
125 'ControlColorUPP',
126 'ControlKind', # XXX easy: 2-tuple containing 2 OSType's
Just van Rossum66d78bf2001-12-18 12:47:47 +0000127# 'ControlTabEntry_ptr', # XXX needed for tabs
128# 'ControlButtonContentInfoPtr',
129# 'ControlButtonContentInfo', # XXX ugh: a union
130# 'ControlButtonContentInfo_ptr', # XXX ugh: a union
Just van Rossume0b9fdc2001-12-12 22:40:27 +0000131 'ListDefSpec_ptr', # XXX see _Listmodule.c, tricky but possible
132 'DataBrowserItemID_ptr', # XXX array of UInt32, for BrowserView
133 'DataBrowserItemUPP',
134 'DataBrowserItemDataRef', # XXX void *
135 'DataBrowserCallbacks', # difficult struct
136 'DataBrowserCallbacks_ptr',
137 'DataBrowserCustomCallbacks',
138 'DataBrowserCustomCallbacks_ptr',
Just van Rossum66d78bf2001-12-18 12:47:47 +0000139## 'DataBrowserTableViewColumnDesc',
140## 'DataBrowserListViewColumnDesc',
Just van Rossume0b9fdc2001-12-12 22:40:27 +0000141 'CFDataRef',
Guido van Rossum17448e21995-01-30 11:53:55 +0000142 ]
143
144 def makerepairinstructions(self):
145 return [
146 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
147 [("InBuffer", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000148
Guido van Rossum17448e21995-01-30 11:53:55 +0000149 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
150 ("long", "*", "OutMode")],
151 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000152
Jack Jansen848250c1998-05-28 14:20:09 +0000153## # For TrackControl
154## ([("ProcPtr", "actionProc", "InMode")],
155## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
156## ([("ControlActionUPP", "actionProc", "InMode")],
157## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000158
Jack Jansen41009001999-03-07 20:05:20 +0000159 # For GetControlTitle
160 ([('Str255', 'title', 'InMode')],
161 [('Str255', 'title', 'OutMode')]),
Jack Jansen229c0861999-12-09 16:03:50 +0000162
Guido van Rossum17448e21995-01-30 11:53:55 +0000163 ([("ControlHandle", "*", "OutMode")],
164 [("ExistingControlHandle", "*", "*")]),
Jack Jansenae8a68f1995-06-06 12:55:40 +0000165 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
166 [("ExistingControlHandle", "*", "*")]),
Jack Jansena9e3db32001-01-09 22:10:16 +0000167
168 ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
169 [("void", "*", "ReturnMode")]),
Just van Rossum66d78bf2001-12-18 12:47:47 +0000170
171 ([("DataBrowserListViewColumnDesc", "*", "OutMode")],
172 [("DataBrowserListViewColumnDesc", "*", "InMode")]),
173
174 ([("ControlButtonContentInfoPtr", 'outContent', "InMode")],
175 [("ControlButtonContentInfoPtr", '*', "OutMode")]),
176
177 ([("ControlButtonContentInfo", '*', "OutMode")],
178 [("ControlButtonContentInfo", '*', "InMode")]),
Just van Rossumcae6da62001-12-30 21:25:26 +0000179
180 ([("ControlActionUPP", 'liveTrackingProc', "InMode")],
181 [("ControlActionUPPNewControl", 'liveTrackingProc', "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000182 ]
183
184if __name__ == "__main__":
185 main()