Allow comment characters (#) to be escaped:
[python/dscho.git] / Mac / Modules / ctl / ctlscan.py
blobaba07c5e18b90aa2f7e4e2ce463a3d0b4d13af94
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"
12 output = "ctlgen.py"
13 defsoutput = TOOLBOXDIR + "Controls.py"
14 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 ==="
21 class MyScanner(Scanner):
23 def destination(self, type, name, arglist):
24 classname = "Function"
25 listname = "functions"
26 if arglist:
27 t, n, m = arglist[0]
28 if t in ("ControlHandle", "ControlRef") and m == "InMode":
29 classname = "Method"
30 listname = "methods"
31 return classname, listname
33 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")
39 def makeblacklistnames(self):
40 return [
41 'DisposeControl', # Generated manually
42 'KillControls', # Implied by close of dialog
43 'SetCtlAction',
44 'TrackControl', # Generated manually
45 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
46 'kControlProgressBarIndeterminateTag', # ditto
47 # The following are unavailable for static 68k (appearance manager)
48 'GetBevelButtonMenuValue',
49 'SetBevelButtonMenuValue',
50 'GetBevelButtonMenuHandle',
51 'SetBevelButtonTransform',
52 'SetBevelButtonGraphicAlignment',
53 'SetBevelButtonTextAlignment',
54 'SetBevelButtonTextPlacement',
55 'SetImageWellTransform',
56 'GetTabContentRect',
57 'SetTabEnabled',
58 'SetDisclosureTriangleLastValue',
59 # Unavailable in CW Pro 3 libraries
60 'SetUpControlTextColor',
63 def makeblacklisttypes(self):
64 return [
65 'ProcPtr',
66 'ControlActionUPP',
67 'ControlButtonContentInfoPtr',
68 'Ptr',
71 def makerepairinstructions(self):
72 return [
73 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
74 [("InBuffer", "*", "*")]),
76 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
77 ("long", "*", "OutMode")],
78 [("VarVarOutBuffer", "*", "InOutMode")]),
80 ## # For TrackControl
81 ## ([("ProcPtr", "actionProc", "InMode")],
82 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
83 ## ([("ControlActionUPP", "actionProc", "InMode")],
84 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
86 # For GetControlTitle
87 ([('Str255', 'title', 'InMode')],
88 [('Str255', 'title', 'OutMode')]),
90 ([("ControlHandle", "*", "OutMode")],
91 [("ExistingControlHandle", "*", "*")]),
92 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
93 [("ExistingControlHandle", "*", "*")]),
96 if __name__ == "__main__":
97 main()