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.)
10 from bgenlocations
import TOOLBOXDIR
, BGENDIR
11 sys
.path
.append(BGENDIR
)
13 from scantools
import Scanner
16 print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
17 input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
19 defsoutput
= TOOLBOXDIR
+ "AppleEvents.py"
20 scanner
= AppleEventsScanner(input, output
, defsoutput
)
23 print "=== Testing definitions output code ==="
24 execfile(defsoutput
, {}, {})
25 print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
27 print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
29 class AppleEventsScanner(Scanner
):
31 def destination(self
, type, name
, arglist
):
32 classname
= "AEFunction"
33 listname
= "functions"
36 if t
[-4:] == "_ptr" and m
== "InMode" and \
37 t
[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
38 "AERecord", "AppleEvent"):
39 classname
= "AEMethod"
40 listname
= "aedescmethods"
41 return classname
, listname
43 def makeblacklistnames(self
):
46 # "AEGetEventHandler",
47 "AEGetDescData", # Use object.data
48 "AEGetSpecialHandler",
49 # Constants with funny definitions
50 "kAEDontDisposeOnResume",
51 "kAEUseStandardDispatch",
54 def makeblacklisttypes(self
):
58 "AECoercionHandlerUPP",
64 def makerepairinstructions(self
):
66 ([("Boolean", "isSysHandler", "InMode")],
67 [("AlwaysFalse", "*", "*")]),
69 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
70 [("InBuffer", "*", "*")]),
72 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
73 [("EventHandler", "*", "*")]),
75 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
76 [("EventHandler", "*", "*")]),
78 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
79 [("EventHandler", "*", "*")]),
81 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
82 [("EventHandler", "*", "*")]),
84 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
85 ("Size", "*", "OutMode")],
86 [("VarVarOutBuffer", "*", "InOutMode")]),
88 ([("AppleEvent", "theAppleEvent", "OutMode")],
89 [("AppleEvent_ptr", "*", "InMode")]),
91 ([("AEDescList", "theAEDescList", "OutMode")],
92 [("AEDescList_ptr", "*", "InMode")]),
95 def writeinitialdefs(self
):
96 self
.defsfile
.write("def FOUR_CHAR_CODE(x): return x\n")
98 if __name__
== "__main__":