blob: ae0462f821e31f9fa1bcff15d15c44573199721b [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001# Scan an Apple header file, generating a Python file of generator calls.
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002import addpack
3addpack.addpack(':Tools:bgen:bgen')
Jack Jansen46d9e791996-04-12 16:29:23 +00004from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +00005
6from scantools import Scanner
7
8def main():
Jack Jansen21f96871998-02-20 16:02:09 +00009 input = "MacWindows.h"
Guido van Rossum17448e21995-01-30 11:53:55 +000010 output = "wingen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000011 defsoutput = TOOLBOXDIR + "Windows.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000012 scanner = MyScanner(input, output, defsoutput)
13 scanner.scan()
14 scanner.close()
15 print "=== Done scanning and generating, now importing the generated code... ==="
16 import winsupport
17 print "=== Done. It's up to you to compile it now! ==="
18
19class MyScanner(Scanner):
20
21 def destination(self, type, name, arglist):
22 classname = "Function"
23 listname = "functions"
24 if arglist:
25 t, n, m = arglist[0]
Jack Jansenb81cf9d1995-06-06 13:08:40 +000026 if t in ("WindowPtr", "WindowPeek", "WindowRef") and m == "InMode":
Guido van Rossum17448e21995-01-30 11:53:55 +000027 classname = "Method"
28 listname = "methods"
29 return classname, listname
30
Jack Jansen21f96871998-02-20 16:02:09 +000031 def writeinitialdefs(self):
32 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
33
Guido van Rossum17448e21995-01-30 11:53:55 +000034 def makeblacklistnames(self):
35 return [
36 'DisposeWindow', # Implied when the object is deleted
37 'CloseWindow',
38 ]
39
40 def makeblacklisttypes(self):
41 return [
42 'ProcPtr',
Jack Jansenb7abb181995-11-15 15:18:47 +000043 'DragGrayRgnUPP',
Guido van Rossum17448e21995-01-30 11:53:55 +000044 ]
45
46 def makerepairinstructions(self):
47 return [
48
49 # GetWTitle
50 ([("Str255", "*", "InMode")],
51 [("*", "*", "OutMode")]),
52
53 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
54 [("InBuffer", "*", "*")]),
55
56 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
57 ("long", "*", "OutMode")],
58 [("VarVarOutBuffer", "*", "InOutMode")]),
59
60 ([("void", "wStorage", "OutMode")],
61 [("NullStorage", "*", "InMode")]),
62
63 ([("WindowPtr", "*", "OutMode")],
64 [("ExistingWindowPtr", "*", "*")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000065 ([("WindowRef", "*", "OutMode")], # Same, but other style headerfiles
66 [("ExistingWindowPtr", "*", "*")]),
Guido van Rossumea39abd1995-02-28 09:49:02 +000067
68 ([("WindowPtr", "FrontWindow", "ReturnMode")],
69 [("ExistingWindowPtr", "*", "*")]),
Jack Jansenb81cf9d1995-06-06 13:08:40 +000070 ([("WindowRef", "FrontWindow", "ReturnMode")], # Ditto
71 [("ExistingWindowPtr", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000072 ]
73
74if __name__ == "__main__":
75 main()
Guido van Rossumea39abd1995-02-28 09:49:02 +000076