Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1 | # Scan AppleEvents.h header file, generate aegen.py and AppleEvents.py files. |
| 2 | # Then run aesupport to generate AEmodule.c. |
| 3 | 0# (Should learn how to tell the compiler to compile it as well.) |
| 4 | |
Jack Jansen | c7cfb95 | 1995-06-05 22:34:12 +0000 | [diff] [blame] | 5 | import addpack |
| 6 | addpack.addpack(':Tools:bgen:bgen') |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 7 | import sys |
| 8 | import os |
| 9 | import string |
| 10 | import regex |
| 11 | import regsub |
| 12 | import MacOS |
| 13 | |
| 14 | from scantools import Scanner |
| 15 | |
| 16 | def main(): |
| 17 | input = "AppleEvents.h" |
| 18 | output = "aegen.py" |
| 19 | defsoutput = "AppleEvents.py" |
| 20 | scanner = AppleEventsScanner(input, output, defsoutput) |
| 21 | 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 | |
| 27 | class 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", |
| 44 | "AEGetEventHandler", |
| 45 | ] |
| 46 | |
| 47 | def makeblacklisttypes(self): |
| 48 | return [ |
| 49 | "ProcPtr", |
| 50 | "AEArrayType", |
Jack Jansen | c7cfb95 | 1995-06-05 22:34:12 +0000 | [diff] [blame] | 51 | "AECoercionHandlerUPP", |
| 52 | "UniversalProcPtr", |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 53 | ] |
| 54 | |
| 55 | def makerepairinstructions(self): |
| 56 | return [ |
| 57 | ([("Boolean", "isSysHandler", "InMode")], |
| 58 | [("AlwaysFalse", "*", "*")]), |
| 59 | |
| 60 | ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")], |
| 61 | [("InBuffer", "*", "*")]), |
| 62 | |
| 63 | ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")], |
| 64 | [("EventHandler", "*", "*")]), |
| 65 | |
| 66 | ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")], |
| 67 | [("EventHandler", "*", "*")]), |
| 68 | |
| 69 | ([("void", "*", "OutMode"), ("Size", "*", "InMode"), |
| 70 | ("Size", "*", "OutMode")], |
| 71 | [("VarVarOutBuffer", "*", "InOutMode")]), |
Jack Jansen | c7cfb95 | 1995-06-05 22:34:12 +0000 | [diff] [blame] | 72 | |
| 73 | ([("AppleEvent", "theAppleEvent", "OutMode")], |
| 74 | [("AppleEvent_ptr", "*", "InMode")]), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 75 | ] |
| 76 | |
| 77 | if __name__ == "__main__": |
| 78 | main() |