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.)
6 addpack
.addpack(':Tools:bgen:bgen')
13 from bgenlocations
import TOOLBOXDIR
15 from scantools
import Scanner
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
)
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.
30 output
= "@dummy-objects.py"
31 defsoutput
= TOOLBOXDIR
+ "AEObjects.py"
32 scanner
= AppleEventsScanner(input, output
, defsoutput
)
35 print "=== Scanning AEDataModel.h ==="
36 input = "AEDataModel.h"
37 output
= "aedatamodelgen.py"
38 defsoutput
= TOOLBOXDIR
+ "AEDataModel.py"
39 scanner
= AppleEventsScanner(input, output
, defsoutput
)
43 print "=== Scanning AppleEvents.h ==="
44 input = "AppleEvents.h"
46 defsoutput
= TOOLBOXDIR
+ "AppleEvents.py"
47 scanner
= AppleEventsRegScanner(input, output
, defsoutput
)
50 print "=== Done Scanning and Generating, now doing '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"
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
):
71 # "AEGetEventHandler",
74 def makeblacklisttypes(self
):
78 "AECoercionHandlerUPP",
82 def makerepairinstructions(self
):
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__":