| 1 | # Scan AppleEvents.h header file, generate aegen.py and AppleEvents.py files.
|
|---|
| 2 | # Then run aesupport to generate AEmodule.c.
|
|---|
| 3 | # (Should learn how to tell the compiler to compile it as well.)
|
|---|
| 4 |
|
|---|
| 5 | import sys
|
|---|
| 6 | import os
|
|---|
| 7 | import string
|
|---|
| 8 | import MacOS
|
|---|
| 9 |
|
|---|
| 10 | from bgenlocations import TOOLBOXDIR, BGENDIR
|
|---|
| 11 | sys.path.append(BGENDIR)
|
|---|
| 12 |
|
|---|
| 13 | from scantools import Scanner
|
|---|
| 14 |
|
|---|
| 15 | def main():
|
|---|
| 16 | print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
|
|---|
| 17 | input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
|
|---|
| 18 | output = "aegen.py"
|
|---|
| 19 | defsoutput = TOOLBOXDIR + "AppleEvents.py"
|
|---|
| 20 | scanner = AppleEventsScanner(input, output, defsoutput)
|
|---|
| 21 | scanner.scan()
|
|---|
| 22 | scanner.close()
|
|---|
| 23 | print "=== Testing definitions output code ==="
|
|---|
| 24 | execfile(defsoutput, {}, {})
|
|---|
| 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 |
|
|---|
| 29 | class 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",
|
|---|
| 46 | # "AEGetEventHandler",
|
|---|
| 47 | "AEGetDescData", # Use object.data
|
|---|
| 48 | "AEGetSpecialHandler",
|
|---|
| 49 | # Constants with funny definitions
|
|---|
| 50 | "kAEDontDisposeOnResume",
|
|---|
| 51 | "kAEUseStandardDispatch",
|
|---|
| 52 | ]
|
|---|
| 53 |
|
|---|
| 54 | def makeblacklisttypes(self):
|
|---|
| 55 | return [
|
|---|
| 56 | "ProcPtr",
|
|---|
| 57 | "AEArrayType",
|
|---|
| 58 | "AECoercionHandlerUPP",
|
|---|
| 59 | "UniversalProcPtr",
|
|---|
| 60 | "OSLCompareUPP",
|
|---|
| 61 | "OSLAccessorUPP",
|
|---|
| 62 | ]
|
|---|
| 63 |
|
|---|
| 64 | def makerepairinstructions(self):
|
|---|
| 65 | return [
|
|---|
| 66 | ([("Boolean", "isSysHandler", "InMode")],
|
|---|
| 67 | [("AlwaysFalse", "*", "*")]),
|
|---|
| 68 |
|
|---|
| 69 | ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
|
|---|
| 70 | [("InBuffer", "*", "*")]),
|
|---|
| 71 |
|
|---|
| 72 | ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
|
|---|
| 73 | [("EventHandler", "*", "*")]),
|
|---|
| 74 |
|
|---|
| 75 | ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
|
|---|
| 76 | [("EventHandler", "*", "*")]),
|
|---|
| 77 |
|
|---|
| 78 | ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
|
|---|
| 79 | [("EventHandler", "*", "*")]),
|
|---|
| 80 |
|
|---|
| 81 | ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
|
|---|
| 82 | [("EventHandler", "*", "*")]),
|
|---|
| 83 |
|
|---|
| 84 | ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
|
|---|
| 85 | ("Size", "*", "OutMode")],
|
|---|
| 86 | [("VarVarOutBuffer", "*", "InOutMode")]),
|
|---|
| 87 |
|
|---|
| 88 | ([("AppleEvent", "theAppleEvent", "OutMode")],
|
|---|
| 89 | [("AppleEvent_ptr", "*", "InMode")]),
|
|---|
| 90 |
|
|---|
| 91 | ([("AEDescList", "theAEDescList", "OutMode")],
|
|---|
| 92 | [("AEDescList_ptr", "*", "InMode")]),
|
|---|
| 93 | ]
|
|---|
| 94 |
|
|---|
| 95 | def writeinitialdefs(self):
|
|---|
| 96 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
|
|---|
| 97 |
|
|---|
| 98 | if __name__ == "__main__":
|
|---|
| 99 | main()
|
|---|