Fix an amazing number of typos & malformed sentences reported by Detlef
[python/dscho.git] / Mac / Modules / win / winscan.py
blobf15fb168cc04e9aecfd5bd57ed74d6c9bbd11c89
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',
42 def makeblacklisttypes(self):
43 return [
44 'ProcPtr',
45 'DragGrayRgnUPP',
48 def makerepairinstructions(self):
49 return [
51 # GetWTitle
52 ([("Str255", "*", "InMode")],
53 [("*", "*", "OutMode")]),
55 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
56 [("InBuffer", "*", "*")]),
58 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
59 ("long", "*", "OutMode")],
60 [("VarVarOutBuffer", "*", "InOutMode")]),
62 ([("void", "wStorage", "OutMode")],
63 [("NullStorage", "*", "InMode")]),
65 ([("WindowPtr", "*", "OutMode")],
66 [("ExistingWindowPtr", "*", "*")]),
67 ([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles
68 [("ExistingWindowPtr", "*", "*")]),
70 ([("WindowPtr", "FrontWindow", "ReturnMode")],
71 [("ExistingWindowPtr", "*", "*")]),
72 ([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto
73 [("ExistingWindowPtr", "*", "*")]),
76 if __name__ == "__main__":
77 main()