blob: e124c5a11cece577ca233f9e9d64c31fdc5e41f8 [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 Jansen21f96871998-02-20 16:02:09 +000044 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
45 'kControlProgressBarIndeterminateTag', # ditto
46 # The following are unavailable for static 68k (appearance manager)
47 'GetBevelButtonMenuValue',
48 'SetBevelButtonMenuValue',
49 'GetBevelButtonMenuHandle',
50 'SetBevelButtonTransform',
51 'SetBevelButtonGraphicAlignment',
52 'SetBevelButtonTextAlignment',
53 'SetBevelButtonTextPlacement',
54 'SetImageWellTransform',
55 'GetTabContentRect',
56 'SetTabEnabled',
57 'SetDisclosureTriangleLastValue',
Jack Jansen1c4e6141998-04-21 15:23:55 +000058 # Unavailable in CW Pro 3 libraries
59 'SetUpControlTextColor',
Guido van Rossum17448e21995-01-30 11:53:55 +000060 ]
61
62 def makeblacklisttypes(self):
63 return [
64 'ProcPtr',
Jack Jansenae8a68f1995-06-06 12:55:40 +000065 'ControlActionUPP',
Jack Jansen21f96871998-02-20 16:02:09 +000066 'ControlButtonContentInfoPtr',
67 'Ptr',
Guido van Rossum17448e21995-01-30 11:53:55 +000068 ]
69
70 def makerepairinstructions(self):
71 return [
72 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
73 [("InBuffer", "*", "*")]),
74
75 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
76 ("long", "*", "OutMode")],
77 [("VarVarOutBuffer", "*", "InOutMode")]),
78
79 # For TrackControl
80 ([("ProcPtr", "actionProc", "InMode")],
81 [("FakeType('(ControlActionUPP)0')", "*", "*")]),
Jack Jansenae8a68f1995-06-06 12:55:40 +000082 ([("ControlActionUPP", "actionProc", "InMode")],
83 [("FakeType('(ControlActionUPP)0')", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000084
85 ([("ControlHandle", "*", "OutMode")],
86 [("ExistingControlHandle", "*", "*")]),
Jack Jansenae8a68f1995-06-06 12:55:40 +000087 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
88 [("ExistingControlHandle", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000089 ]
90
91if __name__ == "__main__":
92 main()