Added 'description' class attribute to every command class (to help the
[python/dscho.git] / Mac / Modules / win / winscan.py
blob22f0d1a45c8e1fe96aa8b018dd4db3b7f47f1b01
1 # Scan an Apple header file, generating a Python file of generator calls.
2 import sys
3 import os
4 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
5 sys.path.append(BGENDIR)
6 from bgenlocations import TOOLBOXDIR
8 from scantools import Scanner
10 def main():
11 input = "MacWindows.h"
12 output = "wingen.py"
13 defsoutput = TOOLBOXDIR + "Windows.py"
14 scanner = MyScanner(input, output, defsoutput)
15 scanner.scan()
16 scanner.close()
17 print "=== Done scanning and generating, now importing the generated code... ==="
18 import winsupport
19 print "=== Done. It's up to you to compile it now! ==="
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 ("WindowPtr", "WindowPeek", "WindowRef") 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")
36 def makeblacklistnames(self):
37 return [
38 'DisposeWindow', # Implied when the object is deleted
39 'CloseWindow',
40 'SetWindowProperty', # For the moment
41 'GetWindowProperty',
42 'GetWindowPropertySize',
43 'RemoveWindowProperty',
44 # Constants with funny definitions
45 'kMouseUpOutOfSlop',
48 def makeblacklisttypes(self):
49 return [
50 'ProcPtr',
51 'DragGrayRgnUPP',
52 'Collection', # For now, to be done later
53 'DragReference', # Ditto, dragmodule doesn't export it yet.
56 def makerepairinstructions(self):
57 return [
59 # GetWTitle
60 ([("Str255", "*", "InMode")],
61 [("*", "*", "OutMode")]),
63 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
64 [("InBuffer", "*", "*")]),
66 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
67 ("long", "*", "OutMode")],
68 [("VarVarOutBuffer", "*", "InOutMode")]),
70 ([("void", "wStorage", "OutMode")],
71 [("NullStorage", "*", "InMode")]),
73 ([("WindowPtr", "*", "OutMode")],
74 [("ExistingWindowPtr", "*", "*")]),
75 ([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles
76 [("ExistingWindowPtr", "*", "*")]),
78 ([("WindowPtr", "FrontWindow", "ReturnMode")],
79 [("ExistingWindowPtr", "*", "*")]),
80 ([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto
81 [("ExistingWindowPtr", "*", "*")]),
84 if __name__ == "__main__":
85 main()