blob: 1283c1dcd2525a7a82603777682038d30ad9817e [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():
Tim Peters182b5ac2004-07-18 06:16:08 +000016 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 ==="
Guido van Rossum17448e21995-01-30 11:53:55 +000028
29class AppleEventsScanner(Scanner):
30
Tim Peters182b5ac2004-07-18 06:16:08 +000031 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
Guido van Rossum17448e21995-01-30 11:53:55 +000042
Tim Peters182b5ac2004-07-18 06:16:08 +000043 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",
52 ]
Guido van Rossum17448e21995-01-30 11:53:55 +000053
Tim Peters182b5ac2004-07-18 06:16:08 +000054 def makeblacklisttypes(self):
55 return [
56 "ProcPtr",
57 "AEArrayType",
58 "AECoercionHandlerUPP",
59 "UniversalProcPtr",
60 "OSLCompareUPP",
61 "OSLAccessorUPP",
62 ]
Guido van Rossum17448e21995-01-30 11:53:55 +000063
Tim Peters182b5ac2004-07-18 06:16:08 +000064 def makerepairinstructions(self):
65 return [
66 ([("Boolean", "isSysHandler", "InMode")],
67 [("AlwaysFalse", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000068
Tim Peters182b5ac2004-07-18 06:16:08 +000069 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
70 [("InBuffer", "*", "*")]),
71
72 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
73 [("EventHandler", "*", "*")]),
74
75 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
76 [("EventHandler", "*", "*")]),
77
78 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
79 [("EventHandler", "*", "*")]),
80
81 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
82 [("EventHandler", "*", "*")]),
83
84 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
85 ("Size", "*", "OutMode")],
86 [("VarVarOutBuffer", "*", "InOutMode")]),
87
88 ([("AppleEvent", "theAppleEvent", "OutMode")],
89 [("AppleEvent_ptr", "*", "InMode")]),
90
91 ([("AEDescList", "theAEDescList", "OutMode")],
92 [("AEDescList_ptr", "*", "InMode")]),
93 ]
94
95 def writeinitialdefs(self):
96 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansen21f96871998-02-20 16:02:09 +000097
Guido van Rossum17448e21995-01-30 11:53:55 +000098if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000099 main()