blob: 7007b4afc12a03fa771694da3e7f77e6a31d80a2 [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 regsub
9import MacOS
Jack Jansen0c4d9471998-04-17 14:07:56 +000010
11BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
12sys.path.append(BGENDIR)
Jack Jansen46d9e791996-04-12 16:29:23 +000013from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +000014
15from scantools import Scanner
16
17def main():
Jack Jansen8ed81302000-12-12 22:09:11 +000018 print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
19 input = ["AEDataModel.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
Guido van Rossum17448e21995-01-30 11:53:55 +000020 output = "aegen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000021 defsoutput = TOOLBOXDIR + "AppleEvents.py"
Jack Jansen8ed81302000-12-12 22:09:11 +000022 scanner = AppleEventsScanner(input, output, defsoutput)
Guido van Rossum17448e21995-01-30 11:53:55 +000023 scanner.scan()
24 scanner.close()
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 ==="
28
29class AppleEventsScanner(Scanner):
30
31 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
42
43 def makeblacklistnames(self):
44 return [
45 "AEDisposeDesc",
Jack Jansen50501991995-07-29 13:58:41 +000046# "AEGetEventHandler",
Jack Jansenf7d5aa62000-12-10 23:43:49 +000047 "AEGetDescData", # Use object.data
48 "AEGetSpecialHandler",
Jack Jansenb1b78d81999-12-14 15:47:01 +000049 # Constants with funny definitions
50 "kAEDontDisposeOnResume",
51 "kAEUseStandardDispatch",
Guido van Rossum17448e21995-01-30 11:53:55 +000052 ]
53
Jack Jansenf7d5aa62000-12-10 23:43:49 +000054 def makegreylist(self):
55 return [
56 ('#if TARGET_API_MAC_CARBON', [
57 'AEGetDescDataSize',
58 'AEReplaceDescData',
59 ])]
Guido van Rossum17448e21995-01-30 11:53:55 +000060 def makeblacklisttypes(self):
61 return [
62 "ProcPtr",
63 "AEArrayType",
Jack Jansenc7cfb951995-06-05 22:34:12 +000064 "AECoercionHandlerUPP",
65 "UniversalProcPtr",
Jack Jansen8ed81302000-12-12 22:09:11 +000066 "OSLCompareUPP",
67 "OSLAccessorUPP",
Guido van Rossum17448e21995-01-30 11:53:55 +000068 ]
69
70 def makerepairinstructions(self):
71 return [
72 ([("Boolean", "isSysHandler", "InMode")],
73 [("AlwaysFalse", "*", "*")]),
74
75 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
76 [("InBuffer", "*", "*")]),
77
78 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
79 [("EventHandler", "*", "*")]),
80
81 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
82 [("EventHandler", "*", "*")]),
83
Jack Jansen50501991995-07-29 13:58:41 +000084 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
85 [("EventHandler", "*", "*")]),
86
87 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
88 [("EventHandler", "*", "*")]),
89
Guido van Rossum17448e21995-01-30 11:53:55 +000090 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
91 ("Size", "*", "OutMode")],
92 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansenc7cfb951995-06-05 22:34:12 +000093
94 ([("AppleEvent", "theAppleEvent", "OutMode")],
95 [("AppleEvent_ptr", "*", "InMode")]),
Jack Jansen74335681995-07-17 11:39:04 +000096
97 ([("AEDescList", "theAEDescList", "OutMode")],
98 [("AEDescList_ptr", "*", "InMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +000099 ]
100
Jack Jansen21f96871998-02-20 16:02:09 +0000101 def writeinitialdefs(self):
102 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
103
Guido van Rossum17448e21995-01-30 11:53:55 +0000104if __name__ == "__main__":
105 main()