py-cvs-rel2_1 (Rev 1.2) merge
[python/dscho.git] / Mac / Modules / ctl / ctlscan.py
blob50de24780aafc70ee3d565f60cbd3e274572c70d
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',
82 'SendControlMessage', # Parameter changed from long to void* from UH3.3 to UH3.4
85 def makegreylist(self):
86 return [
87 ('#if !TARGET_API_MAC_CARBON', [
88 'GetAuxiliaryControlRecord',
89 'SetControlColor',
90 # These have suddenly disappeared in UH 3.3.2...
91 ## 'GetBevelButtonMenuValue',
92 ## 'SetBevelButtonMenuValue',
93 ## 'GetBevelButtonMenuHandle',
94 ## 'SetBevelButtonTransform',
95 ## 'SetImageWellTransform',
96 ## 'GetTabContentRect',
97 ## 'SetTabEnabled',
98 ## 'SetDisclosureTriangleLastValue',
99 ]),
100 ('#if TARGET_API_MAC_CARBON', [
101 'IsAutomaticControlDragTrackingEnabledForWindow',
102 'SetAutomaticControlDragTrackingEnabledForWindow',
103 'HandleControlDragReceive',
104 'HandleControlDragTracking',
105 'GetControlByID',
106 'IsControlDragTrackingEnabled',
107 'SetControlDragTrackingEnabled',
108 'GetControlPropertyAttributes',
109 'ChangeControlPropertyAttributes',
110 'GetControlID',
111 'SetControlID',
112 'HandleControlSetCursor',
113 'GetControlClickActivation',
114 'HandleControlContextualMenuClick',
116 ('#if ACCESSOR_CALLS_ARE_FUNCTIONS', [
117 # XXX These are silly, they should be #defined to access the fields
118 # directly. Later...
119 'GetControlBounds',
120 'IsControlHilited',
121 'GetControlHilite',
122 'GetControlOwner',
123 'GetControlDataHandle',
124 'GetControlPopupMenuHandle',
125 'GetControlPopupMenuID',
126 'SetControlDataHandle',
127 'SetControlBounds',
128 'SetControlPopupMenuHandle',
129 'SetControlPopupMenuID',
132 def makeblacklisttypes(self):
133 return [
134 'ProcPtr',
135 'ControlActionUPP',
136 'ControlButtonContentInfoPtr',
137 'Ptr',
138 'ControlDefSpec', # Don't know how to do this yet
139 'ControlDefSpec_ptr', # ditto
140 'Collection', # Ditto
143 def makerepairinstructions(self):
144 return [
145 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
146 [("InBuffer", "*", "*")]),
148 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
149 ("long", "*", "OutMode")],
150 [("VarVarOutBuffer", "*", "InOutMode")]),
152 ## # For TrackControl
153 ## ([("ProcPtr", "actionProc", "InMode")],
154 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
155 ## ([("ControlActionUPP", "actionProc", "InMode")],
156 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
158 # For GetControlTitle
159 ([('Str255', 'title', 'InMode')],
160 [('Str255', 'title', 'OutMode')]),
162 ([("ControlHandle", "*", "OutMode")],
163 [("ExistingControlHandle", "*", "*")]),
164 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
165 [("ExistingControlHandle", "*", "*")]),
167 ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
168 [("void", "*", "ReturnMode")]),
171 if __name__ == "__main__":
172 main()