blob: 21d5299261fbac9bd6162c25c485b06cce39e736 [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
10BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
11sys.path.append(BGENDIR)
Jack Jansen46d9e791996-04-12 16:29:23 +000012from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +000013
14from scantools import Scanner
15
16def main():
Jack Jansen8ed81302000-12-12 22:09:11 +000017 print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
Jack Jansen086f7c32001-12-17 11:47:27 +000018 input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
Guido van Rossum17448e21995-01-30 11:53:55 +000019 output = "aegen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000020 defsoutput = TOOLBOXDIR + "AppleEvents.py"
Jack Jansen8ed81302000-12-12 22:09:11 +000021 scanner = AppleEventsScanner(input, output, defsoutput)
Guido van Rossum17448e21995-01-30 11:53:55 +000022 scanner.scan()
23 scanner.close()
24 print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
25 import aesupport
26 print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
27
28class AppleEventsScanner(Scanner):
29
30 def destination(self, type, name, arglist):
31 classname = "AEFunction"
32 listname = "functions"
33 if arglist:
34 t, n, m = arglist[0]
35 if t[-4:] == "_ptr" and m == "InMode" and \
36 t[:-4] in ("AEDesc", "AEAddressDesc", "AEDescList",
37 "AERecord", "AppleEvent"):
38 classname = "AEMethod"
39 listname = "aedescmethods"
40 return classname, listname
41
42 def makeblacklistnames(self):
43 return [
44 "AEDisposeDesc",
Jack Jansen50501991995-07-29 13:58:41 +000045# "AEGetEventHandler",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000046 "AEGetDescData", # Use object.data
47 "AEGetSpecialHandler",
Jack Jansenb1b78d81999-12-14 15:47:01 +000048 # Constants with funny definitions
49 "kAEDontDisposeOnResume",
50 "kAEUseStandardDispatch",
Guido van Rossum17448e21995-01-30 11:53:55 +000051 ]
52
Jack Jansenf7d5aa62000-12-10 23:43:49 +000053 def makegreylist(self):
54 return [
55 ('#if TARGET_API_MAC_CARBON', [
56 'AEGetDescDataSize',
57 'AEReplaceDescData',
58 ])]
Guido van Rossum17448e21995-01-30 11:53:55 +000059 def makeblacklisttypes(self):
60 return [
61 "ProcPtr",
62 "AEArrayType",
Jack Jansenc7cfb951995-06-05 22:34:12 +000063 "AECoercionHandlerUPP",
64 "UniversalProcPtr",
Jack Jansen8ed81302000-12-12 22:09:11 +000065 "OSLCompareUPP",
66 "OSLAccessorUPP",
Guido van Rossum17448e21995-01-30 11:53:55 +000067 ]
68
69 def makerepairinstructions(self):
70 return [
71 ([("Boolean", "isSysHandler", "InMode")],
72 [("AlwaysFalse", "*", "*")]),
73
74 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
75 [("InBuffer", "*", "*")]),
76
77 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
78 [("EventHandler", "*", "*")]),
79
80 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
81 [("EventHandler", "*", "*")]),
82
Jack Jansen50501991995-07-29 13:58:41 +000083 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
84 [("EventHandler", "*", "*")]),
85
86 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
87 [("EventHandler", "*", "*")]),
88
Guido van Rossum17448e21995-01-30 11:53:55 +000089 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
90 ("Size", "*", "OutMode")],
91 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansenc7cfb951995-06-05 22:34:12 +000092
93 ([("AppleEvent", "theAppleEvent", "OutMode")],
94 [("AppleEvent_ptr", "*", "InMode")]),
Jack Jansen74335681995-07-17 11:39:04 +000095
96 ([("AEDescList", "theAEDescList", "OutMode")],
97 [("AEDescList_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000098 ]
99
Jack Jansen21f96871998-02-20 16:02:09 +0000100 def writeinitialdefs(self):
101 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
102
Guido van Rossum17448e21995-01-30 11:53:55 +0000103if __name__ == "__main__":
104 main()