2 ** An interface to the application scripting related functions of the OSA API.
4 ** GetAppTerminology - given an FSSpec/posix path to an application,
5 ** returns its aevt (scripting terminology) resource(s)
7 ** GetSysTerminology - returns the AppleScript language component's
8 ** aeut (scripting terminology) resource
10 ** Written by Donovan Preston and slightly modified by Jack and HAS.
13 #include "pymactoolbox.h"
15 #include <Carbon/Carbon.h>
19 PyOSA_GetAppTerminology(PyObject
* self
, PyObject
* args
)
21 AEDesc theDesc
= {0,0};
23 ComponentInstance defaultComponent
= NULL
;
24 SInt16 defaultTerminology
= 0;
25 Boolean didLaunch
= 0;
29 if (!PyArg_ParseTuple(args
, "O&|i", PyMac_GetFSSpec
, &fss
, &modeFlags
))
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.
39 defaultComponent
= OpenDefaultComponent (kOSAComponentType
, 'ascr');
40 err
= GetComponentInstanceError (defaultComponent
);
41 if (err
) return PyMac_Error(err
);
42 err
= OSAGetAppTerminology (
50 if (err
) return PyMac_Error(err
);
51 return Py_BuildValue("O&i", AEDesc_New
, &theDesc
, didLaunch
);
55 PyOSA_GetSysTerminology(PyObject
* self
, PyObject
* args
)
57 AEDesc theDesc
= {0,0};
58 ComponentInstance defaultComponent
= NULL
;
59 SInt16 defaultTerminology
= 0;
62 /* Accept any args for sake of backwards compatibility, then ignore them. */
64 defaultComponent
= OpenDefaultComponent (kOSAComponentType
, 'ascr');
65 err
= GetComponentInstanceError (defaultComponent
);
66 if (err
) return PyMac_Error(err
);
67 err
= OSAGetSysTerminology (
73 if (err
) return PyMac_Error(err
);
74 return Py_BuildValue("O&", AEDesc_New
, &theDesc
);
76 #endif /* !__LP64__ */
79 * List of methods defined in the module
81 static struct PyMethodDef OSATerminology_methods
[] =
85 (PyCFunction
) PyOSA_GetAppTerminology
,
87 "Get an application's terminology. GetAppTerminology(path) --> AEDesc"},
89 (PyCFunction
) PyOSA_GetSysTerminology
,
91 "Get the AppleScript language's terminology. GetSysTerminology() --> AEDesc"},
92 #endif /* !__LP64__ */
93 {NULL
, (PyCFunction
) NULL
, 0, NULL
}
97 initOSATerminology(void)
99 if (PyErr_WarnPy3k("In 3.x, OSATerminology is removed.", 1) < 0)
101 Py_InitModule("OSATerminology", OSATerminology_methods
);