test_whitespace_eater_unicode(): Make this test Python 2.1 compatible.
[python/dscho.git] / Mac / Modules / ctl / ctlscan.py
blobf7bd888761af0bebe6cab09c240cca3e4971d016
1 # Scan <Controls.h>, generating ctlgen.py.
2 import sys
3 import os
4 from bgenlocations import TOOLBOXDIR, BGENDIR
5 sys.path.append(BGENDIR)
7 from scantools import Scanner
9 def main():
10 # 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 ==="
23 class MyScanner(Scanner):
25 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
35 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")
47 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
94 # too lazy for now
95 'GetImageWellContentInfo',
96 'GetBevelButtonContentInfo',
97 # OS8 only
98 'GetAuxiliaryControlRecord',
99 'SetControlColor',
102 def makegreylist(self):
103 return [
104 ('#if TARGET_API_MAC_OSX', [
105 'CreateRoundButtonControl',
106 'CreateDisclosureButtonControl',
107 'CreateRelevanceBarControl',
108 'DisableControl',
109 'EnableControl',
110 'IsControlEnabled',
111 'CreateEditUnicodeTextControl',
112 'CopyDataBrowserEditText',
116 def makeblacklisttypes(self):
117 return [
118 'ProcPtr',
119 # 'ControlActionUPP',
120 'Ptr',
121 'ControlDefSpec', # Don't know how to do this yet
122 'ControlDefSpec_ptr', # ditto
123 'Collection', # Ditto
124 # not-yet-supported stuff in Universal Headers 3.4:
125 'ControlColorUPP',
126 'ControlKind', # XXX easy: 2-tuple containing 2 OSType's
127 # 'ControlTabEntry_ptr', # XXX needed for tabs
128 # 'ControlButtonContentInfoPtr',
129 # 'ControlButtonContentInfo', # XXX ugh: a union
130 # 'ControlButtonContentInfo_ptr', # XXX ugh: a union
131 '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',
139 ## 'DataBrowserTableViewColumnDesc',
140 ## 'DataBrowserListViewColumnDesc',
141 'CFDataRef',
144 def makerepairinstructions(self):
145 return [
146 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
147 [("InBuffer", "*", "*")]),
149 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
150 ("long", "*", "OutMode")],
151 [("VarVarOutBuffer", "*", "InOutMode")]),
153 ## # For TrackControl
154 ## ([("ProcPtr", "actionProc", "InMode")],
155 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
156 ## ([("ControlActionUPP", "actionProc", "InMode")],
157 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
159 # For GetControlTitle
160 ([('Str255', 'title', 'InMode')],
161 [('Str255', 'title', 'OutMode')]),
163 ([("ControlHandle", "*", "OutMode")],
164 [("ExistingControlHandle", "*", "*")]),
165 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
166 [("ExistingControlHandle", "*", "*")]),
168 ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
169 [("void", "*", "ReturnMode")]),
171 ([("DataBrowserListViewColumnDesc", "*", "OutMode")],
172 [("DataBrowserListViewColumnDesc", "*", "InMode")]),
174 ([("ControlButtonContentInfoPtr", 'outContent', "InMode")],
175 [("ControlButtonContentInfoPtr", '*', "OutMode")]),
177 ([("ControlButtonContentInfo", '*', "OutMode")],
178 [("ControlButtonContentInfo", '*', "InMode")]),
180 ([("ControlActionUPP", 'liveTrackingProc', "InMode")],
181 [("ControlActionUPPNewControl", 'liveTrackingProc', "InMode")]),
184 if __name__ == "__main__":
185 main()