This is (hopefully) last checkin before releasing 2.1c2 -- get rid of
[python/dscho.git] / Mac / Modules / ctl / ctlscan.py
blob1a502d6ea34eab33972b64405cf91cd442acedf6
1 # Scan <Controls.h>, generating ctlgen.py.
2 import sys
3 import os
4 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
5 sys.path.append(BGENDIR)
7 from scantools import Scanner
8 from bgenlocations import TOOLBOXDIR
10 def main():
11 # input = "Controls.h" # Universal Headers < 3.3
12 input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
13 output = "ctlgen.py"
14 defsoutput = TOOLBOXDIR + "Controls.py"
15 scanner = MyScanner(input, output, defsoutput)
16 scanner.scan()
17 scanner.close()
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 ==="
22 class MyScanner(Scanner):
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
34 def writeinitialdefs(self):
35 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
36 self.defsfile.write("from TextEdit import *\n")
37 self.defsfile.write("from QuickDraw import *\n")
38 self.defsfile.write("from Dragconst import *\n")
39 self.defsfile.write("\n")
41 def makeblacklistnames(self):
42 return [
43 'DisposeControl', # Generated manually
44 'KillControls', # Implied by close of dialog
45 'SetCtlAction',
46 'TrackControl', # Generated manually
47 'HandleControlClick', # Generated manually
48 'SetControlData', # Generated manually
49 'GetControlData', # Generated manually
50 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
51 'kControlProgressBarIndeterminateTag', # ditto
52 # The following are unavailable for static 68k (appearance manager)
53 ## 'GetBevelButtonMenuValue',
54 ## 'SetBevelButtonMenuValue',
55 ## 'GetBevelButtonMenuHandle',
56 ## 'SetBevelButtonTransform',
57 'SetBevelButtonGraphicAlignment',
58 'SetBevelButtonTextAlignment',
59 'SetBevelButtonTextPlacement',
60 ## 'SetImageWellTransform',
61 ## 'GetTabContentRect',
62 ## 'SetTabEnabled',
63 ## 'SetDisclosureTriangleLastValue',
64 ## # Unavailable in CW Pro 3 libraries
65 ## 'SetUpControlTextColor',
66 ## # Unavailable in Jack's CW Pro 5.1 libraries
67 ## 'GetControlRegion',
68 ## 'RemoveControlProperty',
69 ## 'IsValidControlHandle',
70 ## 'SetControl32BitMinimum',
71 ## 'GetControl32BitMinimum',
72 ## 'SetControl32BitMaximum',
73 ## 'GetControl32BitMaximum',
74 ## 'SetControl32BitValue',
75 ## 'GetControl32BitValue',
76 ## 'SetControlViewSize',
77 ## 'GetControlViewSize',
78 # Generally Bad News
79 'GetControlProperty',
80 'SetControlProperty',
81 'GetControlPropertySize',
84 def makegreylist(self):
85 return [
86 ('#if !TARGET_API_MAC_CARBON', [
87 'GetAuxiliaryControlRecord',
88 'SetControlColor',
89 # These have suddenly disappeared in UH 3.3.2...
90 ## 'GetBevelButtonMenuValue',
91 ## 'SetBevelButtonMenuValue',
92 ## 'GetBevelButtonMenuHandle',
93 ## 'SetBevelButtonTransform',
94 ## 'SetImageWellTransform',
95 ## 'GetTabContentRect',
96 ## 'SetTabEnabled',
97 ## 'SetDisclosureTriangleLastValue',
98 ]),
99 ('#if TARGET_API_MAC_CARBON', [
100 'IsAutomaticControlDragTrackingEnabledForWindow',
101 'SetAutomaticControlDragTrackingEnabledForWindow',
102 'HandleControlDragReceive',
103 'HandleControlDragTracking',
104 'GetControlByID',
105 'IsControlDragTrackingEnabled',
106 'SetControlDragTrackingEnabled',
107 'GetControlPropertyAttributes',
108 'ChangeControlPropertyAttributes',
109 'GetControlID',
110 'SetControlID',
111 'HandleControlSetCursor',
112 'GetControlClickActivation',
113 'HandleControlContextualMenuClick',
115 ('#if ACCESSOR_CALLS_ARE_FUNCTIONS', [
116 # XXX These are silly, they should be #defined to access the fields
117 # directly. Later...
118 'GetControlBounds',
119 'IsControlHilited',
120 'GetControlHilite',
121 'GetControlOwner',
122 'GetControlDataHandle',
123 'GetControlPopupMenuHandle',
124 'GetControlPopupMenuID',
125 'SetControlDataHandle',
126 'SetControlBounds',
127 'SetControlPopupMenuHandle',
128 'SetControlPopupMenuID',
131 def makeblacklisttypes(self):
132 return [
133 'ProcPtr',
134 'ControlActionUPP',
135 'ControlButtonContentInfoPtr',
136 'Ptr',
137 'ControlDefSpec', # Don't know how to do this yet
138 'ControlDefSpec_ptr', # ditto
139 'Collection', # Ditto
142 def makerepairinstructions(self):
143 return [
144 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
145 [("InBuffer", "*", "*")]),
147 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
148 ("long", "*", "OutMode")],
149 [("VarVarOutBuffer", "*", "InOutMode")]),
151 ## # For TrackControl
152 ## ([("ProcPtr", "actionProc", "InMode")],
153 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
154 ## ([("ControlActionUPP", "actionProc", "InMode")],
155 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
157 # For GetControlTitle
158 ([('Str255', 'title', 'InMode')],
159 [('Str255', 'title', 'OutMode')]),
161 ([("ControlHandle", "*", "OutMode")],
162 [("ExistingControlHandle", "*", "*")]),
163 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
164 [("ExistingControlHandle", "*", "*")]),
166 ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
167 [("void", "*", "ReturnMode")]),
170 if __name__ == "__main__":
171 main()