blob: e68c9aecd23e13e2a0722057c2ef458e06eed7ba [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001# Scan AppleEvents.h header file, generate aegen.py and AppleEvents.py files.
2# Then run aesupport to generate AEmodule.c.
30# (Should learn how to tell the compiler to compile it as well.)
4
Jack Jansenc7cfb951995-06-05 22:34:12 +00005import addpack
6addpack.addpack(':Tools:bgen:bgen')
Guido van Rossum17448e21995-01-30 11:53:55 +00007import sys
8import os
9import string
10import regex
11import regsub
12import MacOS
13
14from scantools import Scanner
15
16def main():
Jack Jansen74335681995-07-17 11:39:04 +000017 print "=== Scanning AERegistry.h for defines ==="
18 input = "AERegistry.h"
19 output = "@dummy-registry.py"
20 defsoutput = "AERegistry.py"
21 scanner = AppleEventsScanner(input, output, defsoutput)
22 scanner.scan()
23 scanner.close()
24 print "=== Scanning AEObjects.h for defines ==="
25 # XXXX This isn't correct. We only scan AEObjects.h for defines, but there
26 # are some functions in there that are probably useful (the accessor stuff)
27 # once we start writing servers in python.
28 input = "AEObjects.h"
29 output = "@dummy-objects.py"
30 defsoutput = "AEObjects.py"
31 scanner = AppleEventsScanner(input, output, defsoutput)
32 scanner.scan()
33 scanner.close()
34 print "=== Scanning AppleEvents.py ==="
Guido van Rossum17448e21995-01-30 11:53:55 +000035 input = "AppleEvents.h"
36 output = "aegen.py"
37 defsoutput = "AppleEvents.py"
38 scanner = AppleEventsScanner(input, output, defsoutput)
39 scanner.scan()
40 scanner.close()
41 print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
42 import aesupport
43 print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
44
45class AppleEventsScanner(Scanner):
46
47 def destination(self, type, name, arglist):
48 classname = "AEFunction"
49 listname = "functions"
50 if arglist:
51 t, n, m = arglist[0]
52 if t[-4:] == "_ptr" and m == "InMode" and \
53 t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
54 "AERecord", "AppleEvent"):
55 classname = "AEMethod"
56 listname = "aedescmethods"
57 return classname, listname
58
59 def makeblacklistnames(self):
60 return [
61 "AEDisposeDesc",
62 "AEGetEventHandler",
63 ]
64
65 def makeblacklisttypes(self):
66 return [
67 "ProcPtr",
68 "AEArrayType",
Jack Jansenc7cfb951995-06-05 22:34:12 +000069 "AECoercionHandlerUPP",
70 "UniversalProcPtr",
Guido van Rossum17448e21995-01-30 11:53:55 +000071 ]
72
73 def makerepairinstructions(self):
74 return [
75 ([("Boolean", "isSysHandler", "InMode")],
76 [("AlwaysFalse", "*", "*")]),
77
78 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
79 [("InBuffer", "*", "*")]),
80
81 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
82 [("EventHandler", "*", "*")]),
83
84 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
85 [("EventHandler", "*", "*")]),
86
87 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
88 ("Size", "*", "OutMode")],
89 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansenc7cfb951995-06-05 22:34:12 +000090
91 ([("AppleEvent", "theAppleEvent", "OutMode")],
92 [("AppleEvent_ptr", "*", "InMode")]),
Jack Jansen74335681995-07-17 11:39:04 +000093
94 ([("AEDescList", "theAEDescList", "OutMode")],
95 [("AEDescList_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000096 ]
97
98if __name__ == "__main__":
99 main()