blob: 897b6a6e8fe9a94c265b8decf47797e466e9b80d [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
8import regex
9import regsub
10import MacOS
Jack Jansen0c4d9471998-04-17 14:07:56 +000011
12BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
13sys.path.append(BGENDIR)
Jack Jansen46d9e791996-04-12 16:29:23 +000014from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +000015
16from scantools import Scanner
17
18def main():
Jack Jansen8ed81302000-12-12 22:09:11 +000019 print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
20 input = ["AEDataModel.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
Guido van Rossum17448e21995-01-30 11:53:55 +000021 output = "aegen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000022 defsoutput = TOOLBOXDIR + "AppleEvents.py"
Jack Jansen8ed81302000-12-12 22:09:11 +000023 scanner = AppleEventsScanner(input, output, defsoutput)
Guido van Rossum17448e21995-01-30 11:53:55 +000024 scanner.scan()
25 scanner.close()
26 print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
27 import aesupport
28 print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
29
30class AppleEventsScanner(Scanner):
31
32 def destination(self, type, name, arglist):
33 classname = "AEFunction"
34 listname = "functions"
35 if arglist:
36 t, n, m = arglist[0]
37 if t[-4:] == "_ptr" and m == "InMode" and \
38 t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
39 "AERecord", "AppleEvent"):
40 classname = "AEMethod"
41 listname = "aedescmethods"
42 return classname, listname
43
44 def makeblacklistnames(self):
45 return [
46 "AEDisposeDesc",
Jack Jansen50501991995-07-29 13:58:41 +000047# "AEGetEventHandler",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000048 "AEGetDescData", # Use object.data
49 "AEGetSpecialHandler",
Jack Jansenb1b78d81999-12-14 15:47:01 +000050 # Constants with funny definitions
51 "kAEDontDisposeOnResume",
52 "kAEUseStandardDispatch",
Guido van Rossum17448e21995-01-30 11:53:55 +000053 ]
54
Jack Jansenf7d5aa62000-12-10 23:43:49 +000055 def makegreylist(self):
56 return [
57 ('#if TARGET_API_MAC_CARBON', [
58 'AEGetDescDataSize',
59 'AEReplaceDescData',
60 ])]
Guido van Rossum17448e21995-01-30 11:53:55 +000061 def makeblacklisttypes(self):
62 return [
63 "ProcPtr",
64 "AEArrayType",
Jack Jansenc7cfb951995-06-05 22:34:12 +000065 "AECoercionHandlerUPP",
66 "UniversalProcPtr",
Jack Jansen8ed81302000-12-12 22:09:11 +000067 "OSLCompareUPP",
68 "OSLAccessorUPP",
Guido van Rossum17448e21995-01-30 11:53:55 +000069 ]
70
71 def makerepairinstructions(self):
72 return [
73 ([("Boolean", "isSysHandler", "InMode")],
74 [("AlwaysFalse", "*", "*")]),
75
76 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
77 [("InBuffer", "*", "*")]),
78
79 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
80 [("EventHandler", "*", "*")]),
81
82 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
83 [("EventHandler", "*", "*")]),
84
Jack Jansen50501991995-07-29 13:58:41 +000085 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
86 [("EventHandler", "*", "*")]),
87
88 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
89 [("EventHandler", "*", "*")]),
90
Guido van Rossum17448e21995-01-30 11:53:55 +000091 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
92 ("Size", "*", "OutMode")],
93 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansenc7cfb951995-06-05 22:34:12 +000094
95 ([("AppleEvent", "theAppleEvent", "OutMode")],
96 [("AppleEvent_ptr", "*", "InMode")]),
Jack Jansen74335681995-07-17 11:39:04 +000097
98 ([("AEDescList", "theAEDescList", "OutMode")],
99 [("AEDescList_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000100 ]
101
Jack Jansen21f96871998-02-20 16:02:09 +0000102 def writeinitialdefs(self):
103 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
104
Guido van Rossum17448e21995-01-30 11:53:55 +0000105if __name__ == "__main__":
106 main()