blob: 0f46c0e43c3fabfb99aae61aabe20ac2e3afcc94 [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
4BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
5sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +00006
7from scantools import Scanner
Jack Jansenc574b431996-04-12 16:26:59 +00008from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +00009
10def main():
11 input = "Controls.h"
12 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()
17 print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
18 import ctlsupport
19 print "=== Done. It's up to you to compile Ctlmodule.c ==="
20
21class MyScanner(Scanner):
22
23 def destination(self, type, name, arglist):
24 classname = "Function"
25 listname = "functions"
26 if arglist:
27 t, n, m = arglist[0]
Jack Jansenae8a68f1995-06-06 12:55:40 +000028 if t in ("ControlHandle", "ControlRef") and m == "InMode":
Guido van Rossum17448e21995-01-30 11:53:55 +000029 classname = "Method"
30 listname = "methods"
31 return classname, listname
32
Jack Jansen21f96871998-02-20 16:02:09 +000033 def writeinitialdefs(self):
34 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
35 self.defsfile.write("from TextEdit import *\n")
36 self.defsfile.write("from QuickDraw import *\n")
37 self.defsfile.write("\n")
38
Guido van Rossum17448e21995-01-30 11:53:55 +000039 def makeblacklistnames(self):
40 return [
Jack Jansencfb60ee1996-10-01 10:46:46 +000041 'DisposeControl', # Generated manually
Guido van Rossum17448e21995-01-30 11:53:55 +000042 'KillControls', # Implied by close of dialog
43 'SetCtlAction',
Jack Jansen848250c1998-05-28 14:20:09 +000044 'TrackControl', # Generated manually
Jack Jansen229c0861999-12-09 16:03:50 +000045 'HandleControlClick', # Generated manually
46 'SetControlData', # Generated manually
47 'GetControlData', # Generated manually
Jack Jansen21f96871998-02-20 16:02:09 +000048 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
49 'kControlProgressBarIndeterminateTag', # ditto
50 # The following are unavailable for static 68k (appearance manager)
Jack Jansene79dc762000-06-02 21:35:07 +000051## 'GetBevelButtonMenuValue',
52## 'SetBevelButtonMenuValue',
53## 'GetBevelButtonMenuHandle',
54## 'SetBevelButtonTransform',
Jack Jansen21f96871998-02-20 16:02:09 +000055 'SetBevelButtonGraphicAlignment',
56 'SetBevelButtonTextAlignment',
57 'SetBevelButtonTextPlacement',
Jack Jansene79dc762000-06-02 21:35:07 +000058## 'SetImageWellTransform',
59## 'GetTabContentRect',
60## 'SetTabEnabled',
61## 'SetDisclosureTriangleLastValue',
Jack Jansena05ac601999-12-12 21:41:51 +000062## # Unavailable in CW Pro 3 libraries
63## 'SetUpControlTextColor',
64## # Unavailable in Jack's CW Pro 5.1 libraries
65## 'GetControlRegion',
66## 'RemoveControlProperty',
67## 'IsValidControlHandle',
68## 'SetControl32BitMinimum',
69## 'GetControl32BitMinimum',
70## 'SetControl32BitMaximum',
71## 'GetControl32BitMaximum',
72## 'SetControl32BitValue',
73## 'GetControl32BitValue',
74## 'SetControlViewSize',
75## 'GetControlViewSize',
Jack Jansen229c0861999-12-09 16:03:50 +000076 # Generally Bad News
77 'GetControlProperty',
78 'SetControlProperty',
79 'GetControlPropertySize',
Guido van Rossum17448e21995-01-30 11:53:55 +000080 ]
81
Jack Jansene79dc762000-06-02 21:35:07 +000082 def makegreylist(self):
83 return [
84 ('#ifndef TARGET_API_MAC_CARBON', [
85 'GetAuxiliaryControlRecord',
86 'SetControlColor',
87 ])]
88
Guido van Rossum17448e21995-01-30 11:53:55 +000089 def makeblacklisttypes(self):
90 return [
91 'ProcPtr',
Jack Jansenae8a68f1995-06-06 12:55:40 +000092 'ControlActionUPP',
Jack Jansen21f96871998-02-20 16:02:09 +000093 'ControlButtonContentInfoPtr',
94 'Ptr',
Guido van Rossum17448e21995-01-30 11:53:55 +000095 ]
96
97 def makerepairinstructions(self):
98 return [
99 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
100 [("InBuffer", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000101
Guido van Rossum17448e21995-01-30 11:53:55 +0000102 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
103 ("long", "*", "OutMode")],
104 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000105
Jack Jansen848250c1998-05-28 14:20:09 +0000106## # For TrackControl
107## ([("ProcPtr", "actionProc", "InMode")],
108## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
109## ([("ControlActionUPP", "actionProc", "InMode")],
110## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000111
Jack Jansen41009001999-03-07 20:05:20 +0000112 # For GetControlTitle
113 ([('Str255', 'title', 'InMode')],
114 [('Str255', 'title', 'OutMode')]),
Jack Jansen229c0861999-12-09 16:03:50 +0000115
Guido van Rossum17448e21995-01-30 11:53:55 +0000116 ([("ControlHandle", "*", "OutMode")],
117 [("ExistingControlHandle", "*", "*")]),
Jack Jansenae8a68f1995-06-06 12:55:40 +0000118 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
119 [("ExistingControlHandle", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000120 ]
121
122if __name__ == "__main__":
123 main()