blob: 80c198c38a9ff485d915edbe283fa9ba1df8f3db [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001# Scan AppleEvents.h header file, generate aegen.py and AppleEvents.py files.
2# Then run aesupport to generate AEmodule.c.
Jack Jansen0c4d9471998-04-17 14:07:56 +00003# (Should learn how to tell the compiler to compile it as well.)
Guido van Rossum17448e21995-01-30 11:53:55 +00004
5import sys
6import os
7import string
Guido van Rossum17448e21995-01-30 11:53:55 +00008import MacOS
Jack Jansen0c4d9471998-04-17 14:07:56 +00009
Jack Jansenaaebdd62002-08-05 15:39:30 +000010from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +000011sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +000012
13from scantools import Scanner
14
15def main():
Jack Jansen8ed81302000-12-12 22:09:11 +000016 print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
Jack Jansen086f7c32001-12-17 11:47:27 +000017 input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
Guido van Rossum17448e21995-01-30 11:53:55 +000018 output = "aegen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000019 defsoutput = TOOLBOXDIR + "AppleEvents.py"
Jack Jansen8ed81302000-12-12 22:09:11 +000020 scanner = AppleEventsScanner(input, output, defsoutput)
Guido van Rossum17448e21995-01-30 11:53:55 +000021 scanner.scan()
22 scanner.close()
Jack Jansen87eea882002-08-15 21:48:16 +000023 print "=== Testing definitions output code ==="
24 execfile(defsoutput, {}, {})
Guido van Rossum17448e21995-01-30 11:53:55 +000025 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 ==="
28
29class AppleEventsScanner(Scanner):
30
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
42
43 def makeblacklistnames(self):
44 return [
45 "AEDisposeDesc",
Jack Jansen50501991995-07-29 13:58:41 +000046# "AEGetEventHandler",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000047 "AEGetDescData", # Use object.data
48 "AEGetSpecialHandler",
Jack Jansenb1b78d81999-12-14 15:47:01 +000049 # Constants with funny definitions
50 "kAEDontDisposeOnResume",
51 "kAEUseStandardDispatch",
Guido van Rossum17448e21995-01-30 11:53:55 +000052 ]
53
54 def makeblacklisttypes(self):
55 return [
56 "ProcPtr",
57 "AEArrayType",
Jack Jansenc7cfb951995-06-05 22:34:12 +000058 "AECoercionHandlerUPP",
59 "UniversalProcPtr",
Jack Jansen8ed81302000-12-12 22:09:11 +000060 "OSLCompareUPP",
61 "OSLAccessorUPP",
Guido van Rossum17448e21995-01-30 11:53:55 +000062 ]
63
64 def makerepairinstructions(self):
65 return [
66 ([("Boolean", "isSysHandler", "InMode")],
67 [("AlwaysFalse", "*", "*")]),
68
69 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
70 [("InBuffer", "*", "*")]),
71
72 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
73 [("EventHandler", "*", "*")]),
74
75 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
76 [("EventHandler", "*", "*")]),
77
Jack Jansen50501991995-07-29 13:58:41 +000078 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
79 [("EventHandler", "*", "*")]),
80
81 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
82 [("EventHandler", "*", "*")]),
83
Guido van Rossum17448e21995-01-30 11:53:55 +000084 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
85 ("Size", "*", "OutMode")],
86 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansenc7cfb951995-06-05 22:34:12 +000087
88 ([("AppleEvent", "theAppleEvent", "OutMode")],
89 [("AppleEvent_ptr", "*", "InMode")]),
Jack Jansen74335681995-07-17 11:39:04 +000090
91 ([("AEDescList", "theAEDescList", "OutMode")],
92 [("AEDescList_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000093 ]
94
Jack Jansen21f96871998-02-20 16:02:09 +000095 def writeinitialdefs(self):
96 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
97
Guido van Rossum17448e21995-01-30 11:53:55 +000098if __name__ == "__main__":
99 main()