blob: 75003ecc5035cb3850b011547f5c48d27f333d2d [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
5import sys
6import os
7import string
8import regex
9import regsub
10import MacOS
11
12from scantools import Scanner
13
14def main():
15 input = "AppleEvents.h"
16 output = "aegen.py"
17 defsoutput = "AppleEvents.py"
18 scanner = AppleEventsScanner(input, output, defsoutput)
19 scanner.scan()
20 scanner.close()
21 print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
22 import aesupport
23 print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
24
25class AppleEventsScanner(Scanner):
26
27 def destination(self, type, name, arglist):
28 classname = "AEFunction"
29 listname = "functions"
30 if arglist:
31 t, n, m = arglist[0]
32 if t[-4:] == "_ptr" and m == "InMode" and \
33 t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
34 "AERecord", "AppleEvent"):
35 classname = "AEMethod"
36 listname = "aedescmethods"
37 return classname, listname
38
39 def makeblacklistnames(self):
40 return [
41 "AEDisposeDesc",
42 "AEGetEventHandler",
43 ]
44
45 def makeblacklisttypes(self):
46 return [
47 "ProcPtr",
48 "AEArrayType",
49 ]
50
51 def makerepairinstructions(self):
52 return [
53 ([("Boolean", "isSysHandler", "InMode")],
54 [("AlwaysFalse", "*", "*")]),
55
56 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
57 [("InBuffer", "*", "*")]),
58
59 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
60 [("EventHandler", "*", "*")]),
61
62 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
63 [("EventHandler", "*", "*")]),
64
65 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
66 ("Size", "*", "OutMode")],
67 [("VarVarOutBuffer", "*", "InOutMode")]),
68 ]
69
70if __name__ == "__main__":
71 main()