blob: 868b56ec131e6c7c02731aa9ac6b11bf13b308cd [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
Guido van Rossum17448e21995-01-30 11:53:55 +00006import MacOS
Jack Jansen0c4d9471998-04-17 14:07:56 +00007
Jack Jansenaaebdd62002-08-05 15:39:30 +00008from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00009sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +000010
11from scantools import Scanner
12
13def main():
Collin Wintere7bf59f2007-08-30 18:39:28 +000014 print("=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ===")
Tim Peters182b5ac2004-07-18 06:16:08 +000015 input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
16 output = "aegen.py"
17 defsoutput = TOOLBOXDIR + "AppleEvents.py"
18 scanner = AppleEventsScanner(input, output, defsoutput)
19 scanner.scan()
20 scanner.close()
Collin Wintere7bf59f2007-08-30 18:39:28 +000021 print("=== Testing definitions output code ===")
Neal Norwitz01688022007-08-12 00:43:29 +000022 exec(open(defsoutput).read(), {}, {})
Collin Wintere7bf59f2007-08-30 18:39:28 +000023 print("=== Done Scanning and Generating, now doing 'import aesupport' ===")
Tim Peters182b5ac2004-07-18 06:16:08 +000024 import aesupport
Collin Wintere7bf59f2007-08-30 18:39:28 +000025 print("=== Done 'import aesupport'. It's up to you to compile AEmodule.c ===")
Guido van Rossum17448e21995-01-30 11:53:55 +000026
27class AppleEventsScanner(Scanner):
28
Tim Peters182b5ac2004-07-18 06:16:08 +000029 def destination(self, type, name, arglist):
30 classname = "AEFunction"
31 listname = "functions"
32 if arglist:
33 t, n, m = arglist[0]
34 if t[-4:] == "_ptr" and m == "InMode" and \
35 t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
36 "AERecord", "AppleEvent"):
37 classname = "AEMethod"
38 listname = "aedescmethods"
39 return classname, listname
Guido van Rossum17448e21995-01-30 11:53:55 +000040
Tim Peters182b5ac2004-07-18 06:16:08 +000041 def makeblacklistnames(self):
42 return [
43 "AEDisposeDesc",
44# "AEGetEventHandler",
45 "AEGetDescData", # Use object.data
46 "AEGetSpecialHandler",
47 # Constants with funny definitions
48 "kAEDontDisposeOnResume",
49 "kAEUseStandardDispatch",
50 ]
Guido van Rossum17448e21995-01-30 11:53:55 +000051
Tim Peters182b5ac2004-07-18 06:16:08 +000052 def makeblacklisttypes(self):
53 return [
54 "ProcPtr",
55 "AEArrayType",
56 "AECoercionHandlerUPP",
57 "UniversalProcPtr",
58 "OSLCompareUPP",
59 "OSLAccessorUPP",
60 ]
Guido van Rossum17448e21995-01-30 11:53:55 +000061
Tim Peters182b5ac2004-07-18 06:16:08 +000062 def makerepairinstructions(self):
63 return [
64 ([("Boolean", "isSysHandler", "InMode")],
65 [("AlwaysFalse", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000066
Tim Peters182b5ac2004-07-18 06:16:08 +000067 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
68 [("InBuffer", "*", "*")]),
69
70 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
71 [("EventHandler", "*", "*")]),
72
73 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
74 [("EventHandler", "*", "*")]),
75
76 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
77 [("EventHandler", "*", "*")]),
78
79 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
80 [("EventHandler", "*", "*")]),
81
82 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
83 ("Size", "*", "OutMode")],
84 [("VarVarOutBuffer", "*", "InOutMode")]),
85
86 ([("AppleEvent", "theAppleEvent", "OutMode")],
87 [("AppleEvent_ptr", "*", "InMode")]),
88
89 ([("AEDescList", "theAEDescList", "OutMode")],
90 [("AEDescList_ptr", "*", "InMode")]),
91 ]
92
93 def writeinitialdefs(self):
94 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansen21f96871998-02-20 16:02:09 +000095
Guido van Rossum17448e21995-01-30 11:53:55 +000096if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000097 main()