Oops -- Lib/Test should be Lib/test, of course!
[python/dscho.git] / Mac / Modules / ae / aescan.py
blob620a91c8a749cf10a37739b71063b4ba16f9124f
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 = AppleEventsRegScanner(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 AEDataModel.h ==="
36 input = "AEDataModel.h"
37 output = "aedatamodelgen.py"
38 defsoutput = TOOLBOXDIR + "AEDataModel.py"
39 scanner = AppleEventsScanner(input, output, defsoutput)
41 scanner.scan()
42 scanner.close()
43 print "=== Scanning AppleEvents.h ==="
44 input = "AppleEvents.h"
45 output = "aegen.py"
46 defsoutput = TOOLBOXDIR + "AppleEvents.py"
47 scanner = AppleEventsRegScanner(input, output, defsoutput)
48 scanner.scan()
49 scanner.close()
50 print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
51 import aesupport
52 print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
54 class AppleEventsScanner(Scanner):
56 def destination(self, type, name, arglist):
57 classname = "AEFunction"
58 listname = "functions"
59 if arglist:
60 t, n, m = arglist[0]
61 if t[-4:] == "_ptr" and m == "InMode" and \
62 t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
63 "AERecord", "AppleEvent"):
64 classname = "AEMethod"
65 listname = "aedescmethods"
66 return classname, listname
68 def makeblacklistnames(self):
69 return [
70 "AEDisposeDesc",
71 # "AEGetEventHandler",
74 def makeblacklisttypes(self):
75 return [
76 "ProcPtr",
77 "AEArrayType",
78 "AECoercionHandlerUPP",
79 "UniversalProcPtr",
82 def makerepairinstructions(self):
83 return [
84 ([("Boolean", "isSysHandler", "InMode")],
85 [("AlwaysFalse", "*", "*")]),
87 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
88 [("InBuffer", "*", "*")]),
90 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
91 [("EventHandler", "*", "*")]),
93 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
94 [("EventHandler", "*", "*")]),
96 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
97 [("EventHandler", "*", "*")]),
99 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
100 [("EventHandler", "*", "*")]),
102 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
103 ("Size", "*", "OutMode")],
104 [("VarVarOutBuffer", "*", "InOutMode")]),
106 ([("AppleEvent", "theAppleEvent", "OutMode")],
107 [("AppleEvent_ptr", "*", "InMode")]),
109 ([("AEDescList", "theAEDescList", "OutMode")],
110 [("AEDescList_ptr", "*", "InMode")]),
113 def writeinitialdefs(self):
114 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
116 class AppleEventsRegScanner(AppleEventsScanner):
117 def writeinitialdefs(self):
118 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
119 self.defsfile.write("from AEDataModel import *\n")
121 if __name__ == "__main__":
122 main()