Merged revisions 76065 via svnmerge from
[python.git] / Mac / Modules / ae / aescan.py
blobce19a5e25c81e1922dddcf7c9c83f4d04782fa4a
1 # Scan AppleEvents.h header file, generate aegen.py and AppleEvents.py files.
2 # Then run aesupport to generate AEmodule.c.
3 # (Should learn how to tell the compiler to compile it as well.)
5 import sys
6 import MacOS
8 from bgenlocations import TOOLBOXDIR, BGENDIR
9 sys.path.append(BGENDIR)
11 from scantools import Scanner
13 def main():
14 print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
15 input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
16 output = "aegen.py"
17 defsoutput = TOOLBOXDIR + "AppleEvents.py"
18 scanner = AppleEventsScanner(input, output, defsoutput)
19 scanner.scan()
20 scanner.close()
21 print "=== Testing definitions output code ==="
22 execfile(defsoutput, {}, {})
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 ==="
27 class AppleEventsScanner(Scanner):
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
41 def makeblacklistnames(self):
42 return [
43 "AEDisposeDesc",
44 # "AEGetEventHandler",
45 "AEGetDescData", # Use object.data
46 "AEGetSpecialHandler",
47 # Constants with funny definitions
48 "kAEDontDisposeOnResume",
49 "kAEUseStandardDispatch",
52 def makeblacklisttypes(self):
53 return [
54 "ProcPtr",
55 "AEArrayType",
56 "AECoercionHandlerUPP",
57 "UniversalProcPtr",
58 "OSLCompareUPP",
59 "OSLAccessorUPP",
62 def makerepairinstructions(self):
63 return [
64 ([("Boolean", "isSysHandler", "InMode")],
65 [("AlwaysFalse", "*", "*")]),
67 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
68 [("InBuffer", "*", "*")]),
70 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
71 [("EventHandler", "*", "*")]),
73 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
74 [("EventHandler", "*", "*")]),
76 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
77 [("EventHandler", "*", "*")]),
79 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
80 [("EventHandler", "*", "*")]),
82 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
83 ("Size", "*", "OutMode")],
84 [("VarVarOutBuffer", "*", "InOutMode")]),
86 ([("AppleEvent", "theAppleEvent", "OutMode")],
87 [("AppleEvent_ptr", "*", "InMode")]),
89 ([("AEDescList", "theAEDescList", "OutMode")],
90 [("AEDescList_ptr", "*", "InMode")]),
93 def writeinitialdefs(self):
94 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
96 if __name__ == "__main__":
97 main()