2003-03-06 19:02:59 -04:00
|
|
|
/*
|
|
|
|
** This module is a one-trick pony: given an FSSpec it gets the aeut
|
|
|
|
** resources. It was written by Donovan Preston and slightly modified
|
|
|
|
** by Jack.
|
|
|
|
**
|
|
|
|
** It should be considered a placeholder, it will probably be replaced
|
|
|
|
** by a full interface to OpenScripting.
|
|
|
|
*/
|
|
|
|
#include "Python.h"
|
|
|
|
#include "macglue.h"
|
|
|
|
|
|
|
|
#ifdef WITHOUT_FRAMEWORKS
|
|
|
|
#include <OpenScripting.h>
|
|
|
|
#else
|
2003-03-06 19:02:04 -04:00
|
|
|
#include <Carbon/Carbon.h>
|
2003-03-06 19:02:59 -04:00
|
|
|
#endif
|
2003-03-06 19:02:04 -04:00
|
|
|
|
2003-03-06 19:02:59 -04:00
|
|
|
static PyObject *
|
|
|
|
PyOSA_GetAppTerminology(PyObject* self, PyObject* args)
|
|
|
|
{
|
|
|
|
AEDesc theDesc = {0,0};
|
|
|
|
FSSpec fss;
|
|
|
|
ComponentInstance defaultComponent = NULL;
|
|
|
|
SInt16 defaultTerminology = 0;
|
|
|
|
Boolean didLaunch = 0;
|
2003-03-06 19:02:04 -04:00
|
|
|
OSAError err;
|
2003-03-06 19:02:59 -04:00
|
|
|
long modeFlags = 0;
|
2003-03-06 19:02:04 -04:00
|
|
|
|
2003-03-06 19:02:59 -04:00
|
|
|
if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
|
|
|
|
return NULL;
|
2003-03-06 19:02:04 -04:00
|
|
|
|
2003-03-06 19:02:59 -04:00
|
|
|
defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
|
|
|
|
err = GetComponentInstanceError (defaultComponent);
|
|
|
|
if (err) return PyMac_Error(err);
|
2003-03-06 19:02:04 -04:00
|
|
|
err = OSAGetCurrentDialect(defaultComponent, &defaultTerminology);
|
2003-03-06 19:02:59 -04:00
|
|
|
if (err) return PyMac_Error(err);
|
2003-03-06 19:02:04 -04:00
|
|
|
err = OSAGetAppTerminology (
|
|
|
|
defaultComponent,
|
2003-03-06 19:02:59 -04:00
|
|
|
modeFlags,
|
|
|
|
&fss,
|
2003-03-06 19:02:04 -04:00
|
|
|
defaultTerminology,
|
|
|
|
&didLaunch,
|
2003-03-06 19:02:59 -04:00
|
|
|
&theDesc
|
2003-03-06 19:02:04 -04:00
|
|
|
);
|
2003-03-06 19:02:59 -04:00
|
|
|
if (err) return PyMac_Error(err);
|
|
|
|
return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
|
|
|
|
}
|
2003-03-06 19:02:04 -04:00
|
|
|
|
2003-03-06 19:02:59 -04:00
|
|
|
static PyObject *
|
|
|
|
PyOSA_GetSysTerminology(PyObject* self, PyObject* args)
|
|
|
|
{
|
|
|
|
AEDesc theDesc = {0,0};
|
|
|
|
FSSpec fss;
|
|
|
|
ComponentInstance defaultComponent = NULL;
|
|
|
|
SInt16 defaultTerminology = 0;
|
|
|
|
Boolean didLaunch = 0;
|
|
|
|
OSAError err;
|
|
|
|
long modeFlags = 0;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &modeFlags))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
defaultComponent = OpenDefaultComponent (kOSAComponentType, 'ascr');
|
|
|
|
err = GetComponentInstanceError (defaultComponent);
|
|
|
|
if (err) return PyMac_Error(err);
|
|
|
|
err = OSAGetCurrentDialect(defaultComponent, &defaultTerminology);
|
|
|
|
if (err) return PyMac_Error(err);
|
|
|
|
err = OSAGetAppTerminology (
|
2003-03-06 19:02:04 -04:00
|
|
|
defaultComponent,
|
2003-03-06 19:02:59 -04:00
|
|
|
modeFlags,
|
|
|
|
&fss,
|
2003-03-06 19:02:04 -04:00
|
|
|
defaultTerminology,
|
|
|
|
&didLaunch,
|
2003-03-06 19:02:59 -04:00
|
|
|
&theDesc
|
|
|
|
);
|
|
|
|
if (err) return PyMac_Error(err);
|
|
|
|
return Py_BuildValue("O&i", AEDesc_New, &theDesc, didLaunch);
|
2003-03-06 19:02:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* List of methods defined in the module
|
|
|
|
*/
|
2003-03-06 19:02:59 -04:00
|
|
|
static struct PyMethodDef OSATerminology_methods[] =
|
2003-03-06 19:02:04 -04:00
|
|
|
{
|
2003-03-06 19:02:59 -04:00
|
|
|
{"GetAppTerminology",
|
|
|
|
(PyCFunction) PyOSA_GetAppTerminology,
|
|
|
|
METH_VARARGS,
|
|
|
|
"Get an applications terminology, as an AEDesc object."},
|
|
|
|
{"GetSysTerminology",
|
|
|
|
(PyCFunction) PyOSA_GetSysTerminology,
|
|
|
|
METH_VARARGS,
|
|
|
|
"Get an applications system terminology, as an AEDesc object."},
|
|
|
|
{NULL, (PyCFunction) NULL, 0, NULL}
|
2003-03-06 19:02:04 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2003-03-06 19:02:59 -04:00
|
|
|
initOSATerminology(void)
|
2003-03-06 19:02:04 -04:00
|
|
|
{
|
2003-03-06 19:02:59 -04:00
|
|
|
Py_InitModule("OSATerminology", OSATerminology_methods);
|
2003-03-06 19:02:04 -04:00
|
|
|
}
|