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.)
8 from bgenlocations
import TOOLBOXDIR
, BGENDIR
9 sys
.path
.append(BGENDIR
)
11 from scantools
import Scanner
14 print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
15 input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
17 defsoutput
= TOOLBOXDIR
+ "AppleEvents.py"
18 scanner
= AppleEventsScanner(input, output
, defsoutput
)
21 print "=== Testing definitions output code ==="
22 execfile(defsoutput
, {}, {})
23 print "=== Done Scanning and Generating, now doing '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"
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
):
44 # "AEGetEventHandler",
45 "AEGetDescData", # Use object.data
46 "AEGetSpecialHandler",
47 # Constants with funny definitions
48 "kAEDontDisposeOnResume",
49 "kAEUseStandardDispatch",
52 def makeblacklisttypes(self
):
56 "AECoercionHandlerUPP",
62 def makerepairinstructions(self
):
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__":