blob: 8e74e18e8e7de94682597995d64e818d83a8dd7d [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():
17 input = "AppleEvents.h"
18 output = "aegen.py"
19 defsoutput = "AppleEvents.py"
20 scanner = AppleEventsScanner(input, output, defsoutput)
21 scanner.scan()
22 scanner.close()
23 print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
24 import aesupport
25 print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
26
27class AppleEventsScanner(Scanner):
28
29 def destination(self, type, name, arglist):
30 classname = "AEFunction"
31 listname = "functions"
32 if arglist:
33 t, n, m = arglist[0]
34 if t[-4:] == "_ptr" and m == "InMode" and \
35 t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
36 "AERecord", "AppleEvent"):
37 classname = "AEMethod"
38 listname = "aedescmethods"
39 return classname, listname
40
41 def makeblacklistnames(self):
42 return [
43 "AEDisposeDesc",
44 "AEGetEventHandler",
45 ]
46
47 def makeblacklisttypes(self):
48 return [
49 "ProcPtr",
50 "AEArrayType",
Jack Jansenc7cfb951995-06-05 22:34:12 +000051 "AECoercionHandlerUPP",
52 "UniversalProcPtr",
Guido van Rossum17448e21995-01-30 11:53:55 +000053 ]
54
55 def makerepairinstructions(self):
56 return [
57 ([("Boolean", "isSysHandler", "InMode")],
58 [("AlwaysFalse", "*", "*")]),
59
60 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
61 [("InBuffer", "*", "*")]),
62
63 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
64 [("EventHandler", "*", "*")]),
65
66 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
67 [("EventHandler", "*", "*")]),
68
69 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
70 ("Size", "*", "OutMode")],
71 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansenc7cfb951995-06-05 22:34:12 +000072
73 ([("AppleEvent", "theAppleEvent", "OutMode")],
74 [("AppleEvent_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000075 ]
76
77if __name__ == "__main__":
78 main()