symbian-qemu-0.9.1-12/python-2.6.1/Mac/Modules/ae/aescan.py
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     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 MacOS
       
     7 
       
     8 from bgenlocations import TOOLBOXDIR, BGENDIR
       
     9 sys.path.append(BGENDIR)
       
    10 
       
    11 from scantools import Scanner
       
    12 
       
    13 def main():
       
    14     print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ==="
       
    15     input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
       
    16     output = "aegen.py"
       
    17     defsoutput = TOOLBOXDIR + "AppleEvents.py"
       
    18     scanner = AppleEventsScanner(input, output, defsoutput)
       
    19     scanner.scan()
       
    20     scanner.close()
       
    21     print "=== Testing definitions output code ==="
       
    22     execfile(defsoutput, {}, {})
       
    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                 "AEGetDescData", # Use object.data
       
    46                 "AEGetSpecialHandler",
       
    47                 # Constants with funny definitions
       
    48                 "kAEDontDisposeOnResume",
       
    49                 "kAEUseStandardDispatch",
       
    50                 ]
       
    51 
       
    52     def makeblacklisttypes(self):
       
    53         return [
       
    54                 "ProcPtr",
       
    55                 "AEArrayType",
       
    56                 "AECoercionHandlerUPP",
       
    57                 "UniversalProcPtr",
       
    58                 "OSLCompareUPP",
       
    59                 "OSLAccessorUPP",
       
    60                 ]
       
    61 
       
    62     def makerepairinstructions(self):
       
    63         return [
       
    64                 ([("Boolean", "isSysHandler", "InMode")],
       
    65                  [("AlwaysFalse", "*", "*")]),
       
    66 
       
    67                 ([("void_ptr", "*", "InMode"), ("Size", "*", "InMode")],
       
    68                  [("InBuffer", "*", "*")]),
       
    69 
       
    70                 ([("EventHandlerProcPtr", "*", "InMode"), ("long", "*", "InMode")],
       
    71                  [("EventHandler", "*", "*")]),
       
    72 
       
    73                 ([("EventHandlerProcPtr", "*", "OutMode"), ("long", "*", "OutMode")],
       
    74                  [("EventHandler", "*", "*")]),
       
    75 
       
    76                 ([("AEEventHandlerUPP", "*", "InMode"), ("long", "*", "InMode")],
       
    77                  [("EventHandler", "*", "*")]),
       
    78 
       
    79                 ([("AEEventHandlerUPP", "*", "OutMode"), ("long", "*", "OutMode")],
       
    80                  [("EventHandler", "*", "*")]),
       
    81 
       
    82                 ([("void", "*", "OutMode"), ("Size", "*", "InMode"),
       
    83                                             ("Size", "*", "OutMode")],
       
    84                  [("VarVarOutBuffer", "*", "InOutMode")]),
       
    85 
       
    86                 ([("AppleEvent", "theAppleEvent", "OutMode")],
       
    87                  [("AppleEvent_ptr", "*", "InMode")]),
       
    88 
       
    89                 ([("AEDescList", "theAEDescList", "OutMode")],
       
    90                  [("AEDescList_ptr", "*", "InMode")]),
       
    91                 ]
       
    92 
       
    93     def writeinitialdefs(self):
       
    94         self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
       
    95 
       
    96 if __name__ == "__main__":
       
    97     main()