blob: 818541e52bb42384f1445228f30f39a1ffc1858b [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
102 def makeblacklisttypes(self):
103 return [
104 'ProcPtr',
Just van Rossumcae6da62001-12-30 21:25:26 +0000105# 'ControlActionUPP',
Jack Jansen21f96871998-02-20 16:02:09 +0000106 'Ptr',
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000107 'ControlDefSpec', # Don't know how to do this yet
108 'ControlDefSpec_ptr', # ditto
109 'Collection', # Ditto
Just van Rossume0b9fdc2001-12-12 22:40:27 +0000110 # not-yet-supported stuff in Universal Headers 3.4:
111 'ControlColorUPP',
112 'ControlKind', # XXX easy: 2-tuple containing 2 OSType's
Just van Rossum66d78bf2001-12-18 12:47:47 +0000113# 'ControlTabEntry_ptr', # XXX needed for tabs
114# 'ControlButtonContentInfoPtr',
115# 'ControlButtonContentInfo', # XXX ugh: a union
116# 'ControlButtonContentInfo_ptr', # XXX ugh: a union
Just van Rossume0b9fdc2001-12-12 22:40:27 +0000117 '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',
Just van Rossum66d78bf2001-12-18 12:47:47 +0000125## 'DataBrowserTableViewColumnDesc',
126## 'DataBrowserListViewColumnDesc',
Just van Rossume0b9fdc2001-12-12 22:40:27 +0000127 'CFDataRef',
Jack Jansenda6081f2003-12-03 23:20:13 +0000128 'DataBrowserListViewHeaderDesc', # difficult struct
Guido van Rossum17448e21995-01-30 11:53:55 +0000129 ]
130
131 def makerepairinstructions(self):
132 return [
133 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
134 [("InBuffer", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000135
Guido van Rossum17448e21995-01-30 11:53:55 +0000136 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
137 ("long", "*", "OutMode")],
138 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000139
Jack Jansen848250c1998-05-28 14:20:09 +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
Jack Jansen41009001999-03-07 20:05:20 +0000146 # For GetControlTitle
147 ([('Str255', 'title', 'InMode')],
148 [('Str255', 'title', 'OutMode')]),
Jack Jansen229c0861999-12-09 16:03:50 +0000149
Guido van Rossum17448e21995-01-30 11:53:55 +0000150 ([("ControlHandle", "*", "OutMode")],
151 [("ExistingControlHandle", "*", "*")]),
Jack Jansenae8a68f1995-06-06 12:55:40 +0000152 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
153 [("ExistingControlHandle", "*", "*")]),
Jack Jansena9e3db32001-01-09 22:10:16 +0000154
155 ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
156 [("void", "*", "ReturnMode")]),
Just van Rossum66d78bf2001-12-18 12:47:47 +0000157
158 ([("DataBrowserListViewColumnDesc", "*", "OutMode")],
159 [("DataBrowserListViewColumnDesc", "*", "InMode")]),
160
161 ([("ControlButtonContentInfoPtr", 'outContent', "InMode")],
162 [("ControlButtonContentInfoPtr", '*', "OutMode")]),
163
164 ([("ControlButtonContentInfo", '*', "OutMode")],
165 [("ControlButtonContentInfo", '*', "InMode")]),
Just van Rossumcae6da62001-12-30 21:25:26 +0000166
167 ([("ControlActionUPP", 'liveTrackingProc', "InMode")],
168 [("ControlActionUPPNewControl", 'liveTrackingProc', "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000169 ]
170
171if __name__ == "__main__":
172 main()