Another batch of updates...
[python/dscho.git] / Mac / Modules / ae / aescan.py
blob4317195665f545fa4cfdd9a07268cad23891f9d4
1 # Scan AppleEvents.h header file, generate aegen.py and AppleEvents.py files.
2 # Then run aesupport to generate AEmodule.c.
3 0# (Should learn how to tell the compiler to compile it as well.)
5 import addpack
6 addpack.addpack(':Tools:bgen:bgen')
7 import sys
8 import os
9 import string
10 import regex
11 import regsub
12 import MacOS
13 from bgenlocations import TOOLBOXDIR
15 from scantools import Scanner
17 def main():
18 print "=== Scanning AERegistry.h for defines ==="
19 input = "AERegistry.h"
20 output = "@dummy-registry.py"
21 defsoutput = TOOLBOXDIR + "AERegistry.py"
22 scanner = AppleEventsScanner(input, output, defsoutput)
23 scanner.scan()
24 scanner.close()
25 print "=== Scanning AEObjects.h for defines ==="
26 # XXXX This isn't correct. We only scan AEObjects.h for defines, but there
27 # are some functions in there that are probably useful (the accessor stuff)
28 # once we start writing servers in python.
29 input = "AEObjects.h"
30 output = "@dummy-objects.py"
31 defsoutput = TOOLBOXDIR + "AEObjects.py"
32 scanner = AppleEventsScanner(input, output, defsoutput)
33 scanner.scan()
34 scanner.close()
35 print "=== Scanning AppleEvents.py ==="
36 input = "AppleEvents.h"
37 output = "aegen.py"
38 defsoutput = TOOLBOXDIR + "AppleEvents.py"
39 scanner = AppleEventsScanner(input, output, defsoutput)
40 scanner.scan()
41 scanner.close()
42 print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
43 import aesupport
44 print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
46 class AppleEventsScanner(Scanner):
48 def destination(self, type, name, arglist):
49 classname = "AEFunction"
50 listname = "functions"
51 if arglist:
52 t, n, m = arglist[0]
53 if t[-4:] == "_ptr" and m == "InMode" and \
54 t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
55 "AERecord", "AppleEvent"):
56 classname = "AEMethod"
57 listname = "aedescmethods"
58 return classname, listname
60 def makeblacklistnames(self):
61 return [
62 "AEDisposeDesc",
63 # "AEGetEventHandler",
66 def makeblacklisttypes(self):
67 return [
68 "ProcPtr",
69 "AEArrayType",
70 "AECoercionHandlerUPP",
71 "UniversalProcPtr",
74 def makerepairinstructions(self):
75 return [
76 ([("Boolean", "isSysHandler", "InMode")],
77 [("AlwaysFalse", "*", "*")]),
79 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
80 [("InBuffer", "*", "*")]),
82 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
83 [("EventHandler", "*", "*")]),
85 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
86 [("EventHandler", "*", "*")]),
88 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
89 [("EventHandler", "*", "*")]),
91 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
92 [("EventHandler", "*", "*")]),
94 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
95 ("Size", "*", "OutMode")],
96 [("VarVarOutBuffer", "*", "InOutMode")]),
98 ([("AppleEvent", "theAppleEvent", "OutMode")],
99 [("AppleEvent_ptr", "*", "InMode")]),
101 ([("AEDescList", "theAEDescList", "OutMode")],
102 [("AEDescList_ptr", "*", "InMode")]),
105 if __name__ == "__main__":
106 main()