Debian Codegraph @

cpython27/Mac/Modules/ctl/ctlscan.py

raw symbols SCIP
1 # Scan <Controls.h>, generating ctlgen.py.
2 import sys
3 from bgenlocations import TOOLBOXDIR, BGENDIR
4 sys.path.append(BGENDIR)
5
6 from scantools import Scanner
7
8 def main():
9 # 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 ==="
21
22 class MyScanner(Scanner):
23
24 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
33
34 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")
45
46 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
92
93 # too lazy for now
94 'GetImageWellContentInfo',
95 'GetBevelButtonContentInfo',
96 # OS8 only
97 'GetAuxiliaryControlRecord',
98 'SetControlColor',
99 ]
100
101 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 ]
129
130 def makerepairinstructions(self):
131 return [
132 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
133 [("InBuffer", "*", "*")]),
134
135 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
136 ("long", "*", "OutMode")],
137 [("VarVarOutBuffer", "*", "InOutMode")]),
138
139 ## # For TrackControl
140 ## ([("ProcPtr", "actionProc", "InMode")],
141 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
142 ## ([("ControlActionUPP", "actionProc", "InMode")],
143 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
144
145 # For GetControlTitle
146 ([('Str255', 'title', 'InMode')],
147 [('Str255', 'title', 'OutMode')]),
148
149 ([("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 ]
169
170 if __name__ == "__main__":
171 main()