Bump to 2.3.1 to pick up the missing file.
[python/dscho.git] / Mac / Modules / ae / aescan.py
blob3a59ec8561eaea3b68c9b5954d8a33ff4decbab2
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 os
7 import string
8 import MacOS
10 from bgenlocations import TOOLBOXDIR, BGENDIR
11 sys.path.append(BGENDIR)
13 from scantools import Scanner
15 def main():
16 print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
17 input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
18 output = "aegen.py"
19 defsoutput = TOOLBOXDIR + "AppleEvents.py"
20 scanner = AppleEventsScanner(input, output, defsoutput)
21 scanner.scan()
22 scanner.close()
23 print "=== Testing definitions output code ==="
24 execfile(defsoutput, {}, {})
25 print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
26 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"
34 if arglist:
35 t, n, m = arglist[0]
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):
44 return [
45 "AEDisposeDesc",
46 # "AEGetEventHandler",
47 "AEGetDescData", # Use object.data
48 "AEGetSpecialHandler",
49 # Constants with funny definitions
50 "kAEDontDisposeOnResume",
51 "kAEUseStandardDispatch",
54 def makegreylist(self):
55 return [
56 ('#if TARGET_API_MAC_CARBON', [
57 'AEGetDescDataSize',
58 'AEReplaceDescData',
59 ])]
60 def makeblacklisttypes(self):
61 return [
62 "ProcPtr",
63 "AEArrayType",
64 "AECoercionHandlerUPP",
65 "UniversalProcPtr",
66 "OSLCompareUPP",
67 "OSLAccessorUPP",
70 def makerepairinstructions(self):
71 return [
72 ([("Boolean", "isSysHandler", "InMode")],
73 [("AlwaysFalse", "*", "*")]),
75 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
76 [("InBuffer", "*", "*")]),
78 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
79 [("EventHandler", "*", "*")]),
81 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
82 [("EventHandler", "*", "*")]),
84 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
85 [("EventHandler", "*", "*")]),
87 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
88 [("EventHandler", "*", "*")]),
90 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
91 ("Size", "*", "OutMode")],
92 [("VarVarOutBuffer", "*", "InOutMode")]),
94 ([("AppleEvent", "theAppleEvent", "OutMode")],
95 [("AppleEvent_ptr", "*", "InMode")]),
97 ([("AEDescList", "theAEDescList", "OutMode")],
98 [("AEDescList_ptr", "*", "InMode")]),
101 def writeinitialdefs(self):
102 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
104 if __name__ == "__main__":
105 main()