| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
#include "Python.h" |
| 13 |
#include "pymactoolbox.h" |
| 14 |
|
| 15 |
#include <Carbon/Carbon.h> |
| 16 |
|
| 17 |
#if APPLE_SUPPORTS_QUICKTIME |
| 18 |
static PyObject * |
| 19 |
PyOSA_GetAppTerminology(PyObject* self, PyObject* args) |
| 20 |
{ |
| 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 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 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); |
| 52 |
} |
| 53 |
|
| 54 |
static PyObject * |
| 55 |
PyOSA_GetSysTerminology(PyObject* self, PyObject* args) |
| 56 |
{ |
| 57 |
AEDesc theDesc = {0,0}; |
| 58 |
ComponentInstance defaultComponent = NULL; |
| 59 |
SInt16 defaultTerminology = 0; |
| 60 |
OSAError err; |
| 61 |
|
| 62 |
|
| 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); |
| 75 |
} |
| 76 |
#endif |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
static struct PyMethodDef OSATerminology_methods[] = |
| 82 |
{ |
| 83 |
#if APPLE_SUPPORTS_QUICKTIME |
| 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"}, |
| 92 |
#endif |
| 93 |
{NULL, (PyCFunction) NULL, 0, NULL} |
| 94 |
}; |
| 95 |
|
| 96 |
void |
| 97 |
initOSATerminology(void) |
| 98 |
{ |
| 99 |
if (PyErr_WarnPy3k("In 3.x, the OSATerminology module is removed.", 1) < 0) |
| 100 |
return; |
| 101 |
Py_InitModule("OSATerminology", OSATerminology_methods); |
| 102 |
} |