Bump version to 0.9.1.
[python/dscho.git] / Mac / Modules / win / winscan.py
blob88a89192654566de491ac9b564042c39b5b3e41d
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 'MacCloseWindow',
45 # Constants with funny definitions
46 'kMouseUpOutOfSlop',
49 def makegreylist(self):
50 return [
51 ('#if !TARGET_API_MAC_CARBON', [
52 'GetAuxWin',
53 'GetWindowDataHandle',
54 'SaveOld',
55 'DrawNew',
56 'SetWinColor',
57 'SetDeskCPat',
58 'InitWindows',
59 'InitFloatingWindows',
60 'GetWMgrPort',
61 'GetCWMgrPort',
62 'ValidRgn', # Use versions with Window in their name
63 'ValidRect',
64 'InvalRgn',
65 'InvalRect',
66 'IsValidWindowPtr', # I think this is useless for Python, but not sure...
67 ])]
69 def makeblacklisttypes(self):
70 return [
71 'ProcPtr',
72 'DragGrayRgnUPP',
73 'Collection', # For now, to be done later
74 'DragReference', # Ditto, dragmodule doesn't export it yet.
77 def makerepairinstructions(self):
78 return [
80 # GetWTitle
81 ([("Str255", "*", "InMode")],
82 [("*", "*", "OutMode")]),
84 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
85 [("InBuffer", "*", "*")]),
87 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
88 ("long", "*", "OutMode")],
89 [("VarVarOutBuffer", "*", "InOutMode")]),
91 ([("void", "wStorage", "OutMode")],
92 [("NullStorage", "*", "InMode")]),
94 ([("WindowPtr", "*", "OutMode")],
95 [("ExistingWindowPtr", "*", "*")]),
96 ([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles
97 [("ExistingWindowPtr", "*", "*")]),
99 ([("WindowPtr", "FrontWindow", "ReturnMode")],
100 [("ExistingWindowPtr", "*", "*")]),
101 ([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto
102 [("ExistingWindowPtr", "*", "*")]),
105 if __name__ == "__main__":
106 main()