Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Mac/Modules/OSATerminology.c

    r2 r391  
    11/*
    2 ** This module is a one-trick pony: given an FSSpec it gets the aeut
    3 ** resources. It was written by Donovan Preston and slightly modified
    4 ** by Jack.
     2** An interface to the application scripting related functions of the OSA API.
    53**
    6 ** It should be considered a placeholder, it will probably be replaced
    7 ** by a full interface to OpenScripting.
     4** GetAppTerminology - given an FSSpec/posix path to an application,
     5**                         returns its aevt (scripting terminology) resource(s)
     6**
     7** GetSysTerminology - returns the AppleScript language component's
     8**                         aeut (scripting terminology) resource
     9**
     10** Written by Donovan Preston and slightly modified by Jack and HAS.
    811*/
    912#include "Python.h"
     
    1619PyOSA_GetAppTerminology(PyObject* self, PyObject* args)
    1720{
    18         AEDesc theDesc = {0,0};
    19         FSSpec fss;
    20         ComponentInstance defaultComponent = NULL;
    21         SInt16 defaultTerminology = 0;
    22         Boolean didLaunch = 0;
    23         OSAError err;
    24         long modeFlags = 0;
    25        
    26         if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
    27                  return NULL;
    28        
    29         defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
    30         err = GetComponentInstanceError (defaultComponent);
    31         if (err) return PyMac_Error(err);
    32         err = OSAGetAppTerminology (
    33         defaultComponent,
    34         modeFlags,
    35         &fss,
    36         defaultTerminology,
    37         &didLaunch,
    38         &theDesc
    39         );
    40         if (err) return PyMac_Error(err);
    41         return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
     21    AEDesc theDesc = {0,0};
     22    FSSpec fss;
     23    ComponentInstance defaultComponent = NULL;
     24    SInt16 defaultTerminology = 0;
     25    Boolean didLaunch = 0;
     26    OSAError err;
     27    long modeFlags = 0;
     28
     29    if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
     30             return NULL;
     31
     32    /*
     33    ** Note that we have to use the AppleScript component here. Who knows why
     34    ** OSAGetAppTerminology should require a scripting component in the
     35    ** first place, but it does. Note: doesn't work with the generic scripting
     36    ** component, which is unfortunate as the AS component is currently very
     37    ** slow (~1 sec?) to load, but we just have to live with this.
     38    */
     39    defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
     40    err = GetComponentInstanceError (defaultComponent);
     41    if (err) return PyMac_Error(err);
     42    err = OSAGetAppTerminology (
     43    defaultComponent,
     44    kOSAModeNull,
     45    &fss,
     46    defaultTerminology,
     47    &didLaunch,
     48    &theDesc
     49    );
     50    if (err) return PyMac_Error(err);
     51    return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
    4252}
    4353
     
    4555PyOSA_GetSysTerminology(PyObject* self, PyObject* args)
    4656{
    47         AEDesc theDesc = {0,0};
    48         FSSpec fss;
    49         ComponentInstance defaultComponent = NULL;
    50         SInt16 defaultTerminology = 0;
    51         Boolean didLaunch = 0;
    52         OSAError err;
    53         long modeFlags = 0;
    54        
    55         if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
    56                  return NULL;
    57        
    58         defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
    59         err = GetComponentInstanceError (defaultComponent);
    60         if (err) return PyMac_Error(err);
    61         err = OSAGetAppTerminology (
    62         defaultComponent,
    63         modeFlags,
    64         &fss,
    65         defaultTerminology,
    66         &didLaunch,
    67         &theDesc
    68         );
    69         if (err) return PyMac_Error(err);
    70         return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
     57    AEDesc theDesc = {0,0};
     58    ComponentInstance defaultComponent = NULL;
     59    SInt16 defaultTerminology = 0;
     60    OSAError err;
     61
     62    /* Accept any args for sake of backwards compatibility, then ignore them. */
     63
     64    defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
     65    err = GetComponentInstanceError (defaultComponent);
     66    if (err) return PyMac_Error(err);
     67    err = OSAGetSysTerminology (
     68    defaultComponent,
     69    kOSAModeNull,
     70    defaultTerminology,
     71    &theDesc
     72    );
     73    if (err) return PyMac_Error(err);
     74    return Py_BuildValue("O&", AEDesc_New, &theDesc);
    7175}
    7276#endif /* !__LP64__ */
    7377
    74 /* 
     78/*
    7579 * List of methods defined in the module
    7680 */
     
    7882{
    7983#ifndef __LP64__
    80         {"GetAppTerminology",
    81                 (PyCFunction) PyOSA_GetAppTerminology,
    82                 METH_VARARGS,
    83                 "Get an applications terminology, as an AEDesc object."},
    84         {"GetSysTerminology",
    85                 (PyCFunction) PyOSA_GetSysTerminology,
    86                 METH_VARARGS,
    87                 "Get an applications system terminology, as an AEDesc object."},
     84    {"GetAppTerminology",
     85        (PyCFunction) PyOSA_GetAppTerminology,
     86        METH_VARARGS,
     87        "Get an application's terminology. GetAppTerminology(path) --> AEDesc"},
     88    {"GetSysTerminology",
     89        (PyCFunction) PyOSA_GetSysTerminology,
     90        METH_VARARGS,
     91        "Get the AppleScript language's terminology. GetSysTerminology() --> AEDesc"},
    8892#endif /* !__LP64__ */
    89         {NULL, (PyCFunction) NULL, 0, NULL}
     93    {NULL, (PyCFunction) NULL, 0, NULL}
    9094};
    9195
     
    9397initOSATerminology(void)
    9498{
    95         if (PyErr_WarnPy3k("In 3.x, OSATerminology is removed.", 1) < 0)
    96                 return;
    97         Py_InitModule("OSATerminology", OSATerminology_methods);
     99    if (PyErr_WarnPy3k("In 3.x, the OSATerminology module is removed.", 1) < 0)
     100        return;
     101    Py_InitModule("OSATerminology", OSATerminology_methods);
    98102}
Note: See TracChangeset for help on using the changeset viewer.