blob: b406ce784f40a5a3a43c68caa55ff074494061e3 [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()
23 print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
24 import aesupport
25 print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
26
27class AppleEventsScanner(Scanner):
28
29 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
40
41 def makeblacklistnames(self):
42 return [
43 "AEDisposeDesc",
Jack Jansen50501991995-07-29 13:58:41 +000044# "AEGetEventHandler",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000045 "AEGetDescData", # Use object.data
46 "AEGetSpecialHandler",
Jack Jansenb1b78d81999-12-14 15:47:01 +000047 # Constants with funny definitions
48 "kAEDontDisposeOnResume",
49 "kAEUseStandardDispatch",
Guido van Rossum17448e21995-01-30 11:53:55 +000050 ]
51
Jack Jansenf7d5aa62000-12-10 23:43:49 +000052 def makegreylist(self):
53 return [
54 ('#if TARGET_API_MAC_CARBON', [
55 'AEGetDescDataSize',
56 'AEReplaceDescData',
57 ])]
Guido van Rossum17448e21995-01-30 11:53:55 +000058 def makeblacklisttypes(self):
59 return [
60 "ProcPtr",
61 "AEArrayType",
Jack Jansenc7cfb951995-06-05 22:34:12 +000062 "AECoercionHandlerUPP",
63 "UniversalProcPtr",
Jack Jansen8ed81302000-12-12 22:09:11 +000064 "OSLCompareUPP",
65 "OSLAccessorUPP",
Guido van Rossum17448e21995-01-30 11:53:55 +000066 ]
67
68 def makerepairinstructions(self):
69 return [
70 ([("Boolean", "isSysHandler", "InMode")],
71 [("AlwaysFalse", "*", "*")]),
72
73 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
74 [("InBuffer", "*", "*")]),
75
76 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
77 [("EventHandler", "*", "*")]),
78
79 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
80 [("EventHandler", "*", "*")]),
81
Jack Jansen50501991995-07-29 13:58:41 +000082 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
83 [("EventHandler", "*", "*")]),
84
85 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
86 [("EventHandler", "*", "*")]),
87
Guido van Rossum17448e21995-01-30 11:53:55 +000088 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
89 ("Size", "*", "OutMode")],
90 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansenc7cfb951995-06-05 22:34:12 +000091
92 ([("AppleEvent", "theAppleEvent", "OutMode")],
93 [("AppleEvent_ptr", "*", "InMode")]),
Jack Jansen74335681995-07-17 11:39:04 +000094
95 ([("AEDescList", "theAEDescList", "OutMode")],
96 [("AEDescList_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000097 ]
98
Jack Jansen21f96871998-02-20 16:02:09 +000099 def writeinitialdefs(self):
100 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
101
Guido van Rossum17448e21995-01-30 11:53:55 +0000102if __name__ == "__main__":
103 main()