2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
/* =========================== Module _Cm =========================== */
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "pymactoolbox.h"
|
|
|
|
|
|
|
|
/* Macro to test whether a weak-loaded CFM function exists */
|
|
|
|
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
2003-11-19 12:13:35 -04:00
|
|
|
PyErr_SetString(PyExc_NotImplementedError, \
|
|
|
|
"Not available in this shared library/OS version"); \
|
|
|
|
return NULL; \
|
2001-08-23 11:02:09 -03:00
|
|
|
}} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
|
|
|
|
#ifdef USE_TOOLBOX_OBJECT_GLUE
|
|
|
|
extern PyObject *_CmpObj_New(Component);
|
|
|
|
extern int _CmpObj_Convert(PyObject *, Component *);
|
|
|
|
extern PyObject *_CmpInstObj_New(ComponentInstance);
|
|
|
|
extern int _CmpInstObj_Convert(PyObject *, ComponentInstance *);
|
|
|
|
|
|
|
|
#define CmpObj_New _CmpObj_New
|
|
|
|
#define CmpObj_Convert _CmpObj_Convert
|
|
|
|
#define CmpInstObj_New _CmpInstObj_New
|
|
|
|
#define CmpInstObj_Convert _CmpInstObj_Convert
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Parse/generate ComponentDescriptor records
|
|
|
|
*/
|
|
|
|
static PyObject *
|
|
|
|
CmpDesc_New(ComponentDescription *itself)
|
|
|
|
{
|
|
|
|
|
2005-07-03 17:59:44 -03:00
|
|
|
return Py_BuildValue("O&O&O&ll",
|
|
|
|
PyMac_BuildOSType, itself->componentType,
|
|
|
|
PyMac_BuildOSType, itself->componentSubType,
|
|
|
|
PyMac_BuildOSType, itself->componentManufacturer,
|
|
|
|
itself->componentFlags, itself->componentFlagsMask);
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
CmpDesc_Convert(PyObject *v, ComponentDescription *p_itself)
|
|
|
|
{
|
2005-07-03 17:59:44 -03:00
|
|
|
return PyArg_ParseTuple(v, "O&O&O&ll",
|
|
|
|
PyMac_GetOSType, &p_itself->componentType,
|
|
|
|
PyMac_GetOSType, &p_itself->componentSubType,
|
|
|
|
PyMac_GetOSType, &p_itself->componentManufacturer,
|
|
|
|
&p_itself->componentFlags, &p_itself->componentFlagsMask);
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *Cm_Error;
|
|
|
|
|
|
|
|
/* ----------------- Object type ComponentInstance ------------------ */
|
|
|
|
|
|
|
|
PyTypeObject ComponentInstance_Type;
|
|
|
|
|
2007-12-18 22:45:37 -04:00
|
|
|
#define CmpInstObj_Check(x) (Py_TYPE(x) == &ComponentInstance_Type || PyObject_TypeCheck((x), &ComponentInstance_Type))
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
typedef struct ComponentInstanceObject {
|
|
|
|
PyObject_HEAD
|
|
|
|
ComponentInstance ob_itself;
|
|
|
|
} ComponentInstanceObject;
|
|
|
|
|
|
|
|
PyObject *CmpInstObj_New(ComponentInstance itself)
|
|
|
|
{
|
|
|
|
ComponentInstanceObject *it;
|
|
|
|
if (itself == NULL) {
|
2005-07-03 17:59:44 -03:00
|
|
|
PyErr_SetString(Cm_Error,"NULL ComponentInstance");
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-08-23 11:02:09 -03:00
|
|
|
it = PyObject_NEW(ComponentInstanceObject, &ComponentInstance_Type);
|
|
|
|
if (it == NULL) return NULL;
|
|
|
|
it->ob_itself = itself;
|
|
|
|
return (PyObject *)it;
|
|
|
|
}
|
2005-07-03 17:59:44 -03:00
|
|
|
|
2001-09-04 19:19:18 -03:00
|
|
|
int CmpInstObj_Convert(PyObject *v, ComponentInstance *p_itself)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
|
|
|
if (!CmpInstObj_Check(v))
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "ComponentInstance required");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*p_itself = ((ComponentInstanceObject *)v)->ob_itself;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CmpInstObj_dealloc(ComponentInstanceObject *self)
|
|
|
|
{
|
|
|
|
/* Cleanup of self->ob_itself goes here */
|
2007-12-18 22:45:37 -04:00
|
|
|
Py_TYPE(self)->tp_free((PyObject *)self);
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpInstObj_CloseComponent(ComponentInstanceObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef CloseComponent
|
|
|
|
PyMac_PRECHECK(CloseComponent);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = CloseComponent(_self->ob_itself);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpInstObj_GetComponentInstanceError(ComponentInstanceObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetComponentInstanceError
|
|
|
|
PyMac_PRECHECK(GetComponentInstanceError);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = GetComponentInstanceError(_self->ob_itself);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpInstObj_SetComponentInstanceError(ComponentInstanceObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr theError;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef SetComponentInstanceError
|
|
|
|
PyMac_PRECHECK(SetComponentInstanceError);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&theError))
|
|
|
|
return NULL;
|
|
|
|
SetComponentInstanceError(_self->ob_itself,
|
|
|
|
theError);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpInstObj_GetComponentInstanceStorage(ComponentInstanceObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Handle _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetComponentInstanceStorage
|
|
|
|
PyMac_PRECHECK(GetComponentInstanceStorage);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetComponentInstanceStorage(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
ResObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpInstObj_SetComponentInstanceStorage(ComponentInstanceObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Handle theStorage;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef SetComponentInstanceStorage
|
|
|
|
PyMac_PRECHECK(SetComponentInstanceStorage);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &theStorage))
|
|
|
|
return NULL;
|
|
|
|
SetComponentInstanceStorage(_self->ob_itself,
|
|
|
|
theStorage);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpInstObj_ComponentFunctionImplemented(ComponentInstanceObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long _rv;
|
|
|
|
short ftnNumber;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef ComponentFunctionImplemented
|
|
|
|
PyMac_PRECHECK(ComponentFunctionImplemented);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&ftnNumber))
|
|
|
|
return NULL;
|
|
|
|
_rv = ComponentFunctionImplemented(_self->ob_itself,
|
|
|
|
ftnNumber);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpInstObj_GetComponentVersion(ComponentInstanceObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetComponentVersion
|
|
|
|
PyMac_PRECHECK(GetComponentVersion);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetComponentVersion(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpInstObj_ComponentSetTarget(ComponentInstanceObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long _rv;
|
|
|
|
ComponentInstance target;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef ComponentSetTarget
|
|
|
|
PyMac_PRECHECK(ComponentSetTarget);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
CmpInstObj_Convert, &target))
|
|
|
|
return NULL;
|
|
|
|
_rv = ComponentSetTarget(_self->ob_itself,
|
|
|
|
target);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef CmpInstObj_methods[] = {
|
|
|
|
{"CloseComponent", (PyCFunction)CmpInstObj_CloseComponent, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetComponentInstanceError", (PyCFunction)CmpInstObj_GetComponentInstanceError, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"SetComponentInstanceError", (PyCFunction)CmpInstObj_SetComponentInstanceError, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(OSErr theError) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetComponentInstanceStorage", (PyCFunction)CmpInstObj_GetComponentInstanceStorage, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (Handle _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"SetComponentInstanceStorage", (PyCFunction)CmpInstObj_SetComponentInstanceStorage, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(Handle theStorage) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"ComponentFunctionImplemented", (PyCFunction)CmpInstObj_ComponentFunctionImplemented, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(short ftnNumber) -> (long _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetComponentVersion", (PyCFunction)CmpInstObj_GetComponentVersion, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (long _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"ComponentSetTarget", (PyCFunction)CmpInstObj_ComponentSetTarget, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(ComponentInstance target) -> (long _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
2002-11-29 19:40:48 -04:00
|
|
|
#define CmpInstObj_getsetlist NULL
|
2001-08-23 11:02:09 -03:00
|
|
|
|
2002-12-03 19:40:22 -04:00
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
#define CmpInstObj_compare NULL
|
|
|
|
|
|
|
|
#define CmpInstObj_repr NULL
|
|
|
|
|
|
|
|
#define CmpInstObj_hash NULL
|
2002-12-03 19:40:22 -04:00
|
|
|
#define CmpInstObj_tp_init 0
|
|
|
|
|
|
|
|
#define CmpInstObj_tp_alloc PyType_GenericAlloc
|
|
|
|
|
2005-07-03 17:59:44 -03:00
|
|
|
static PyObject *CmpInstObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
|
2002-12-03 19:40:22 -04:00
|
|
|
{
|
2005-07-03 17:59:44 -03:00
|
|
|
PyObject *_self;
|
2002-12-03 19:40:22 -04:00
|
|
|
ComponentInstance itself;
|
|
|
|
char *kw[] = {"itself", 0};
|
|
|
|
|
2005-07-03 17:59:44 -03:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CmpInstObj_Convert, &itself)) return NULL;
|
|
|
|
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
|
|
|
|
((ComponentInstanceObject *)_self)->ob_itself = itself;
|
|
|
|
return _self;
|
2002-12-03 19:40:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define CmpInstObj_tp_free PyObject_Del
|
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
PyTypeObject ComponentInstance_Type = {
|
2007-07-22 11:41:55 -03:00
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
2001-12-08 14:02:58 -04:00
|
|
|
"_Cm.ComponentInstance", /*tp_name*/
|
2001-08-23 11:02:09 -03:00
|
|
|
sizeof(ComponentInstanceObject), /*tp_basicsize*/
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
/* methods */
|
|
|
|
(destructor) CmpInstObj_dealloc, /*tp_dealloc*/
|
|
|
|
0, /*tp_print*/
|
2002-11-29 19:40:48 -04:00
|
|
|
(getattrfunc)0, /*tp_getattr*/
|
|
|
|
(setattrfunc)0, /*tp_setattr*/
|
2001-08-23 11:02:09 -03:00
|
|
|
(cmpfunc) CmpInstObj_compare, /*tp_compare*/
|
|
|
|
(reprfunc) CmpInstObj_repr, /*tp_repr*/
|
|
|
|
(PyNumberMethods *)0, /* tp_as_number */
|
|
|
|
(PySequenceMethods *)0, /* tp_as_sequence */
|
|
|
|
(PyMappingMethods *)0, /* tp_as_mapping */
|
|
|
|
(hashfunc) CmpInstObj_hash, /*tp_hash*/
|
2002-11-29 19:40:48 -04:00
|
|
|
0, /*tp_call*/
|
|
|
|
0, /*tp_str*/
|
|
|
|
PyObject_GenericGetAttr, /*tp_getattro*/
|
|
|
|
PyObject_GenericSetAttr, /*tp_setattro */
|
2002-12-03 19:40:22 -04:00
|
|
|
0, /*tp_as_buffer*/
|
|
|
|
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
|
|
|
|
0, /*tp_doc*/
|
|
|
|
0, /*tp_traverse*/
|
|
|
|
0, /*tp_clear*/
|
|
|
|
0, /*tp_richcompare*/
|
|
|
|
0, /*tp_weaklistoffset*/
|
|
|
|
0, /*tp_iter*/
|
|
|
|
0, /*tp_iternext*/
|
2002-11-29 19:40:48 -04:00
|
|
|
CmpInstObj_methods, /* tp_methods */
|
2002-12-03 19:40:22 -04:00
|
|
|
0, /*tp_members*/
|
2002-11-29 19:40:48 -04:00
|
|
|
CmpInstObj_getsetlist, /*tp_getset*/
|
2002-12-03 19:40:22 -04:00
|
|
|
0, /*tp_base*/
|
|
|
|
0, /*tp_dict*/
|
|
|
|
0, /*tp_descr_get*/
|
|
|
|
0, /*tp_descr_set*/
|
|
|
|
0, /*tp_dictoffset*/
|
|
|
|
CmpInstObj_tp_init, /* tp_init */
|
|
|
|
CmpInstObj_tp_alloc, /* tp_alloc */
|
|
|
|
CmpInstObj_tp_new, /* tp_new */
|
|
|
|
CmpInstObj_tp_free, /* tp_free */
|
2001-08-23 11:02:09 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* --------------- End object type ComponentInstance ---------------- */
|
|
|
|
|
|
|
|
|
|
|
|
/* --------------------- Object type Component ---------------------- */
|
|
|
|
|
|
|
|
PyTypeObject Component_Type;
|
|
|
|
|
2007-12-18 22:45:37 -04:00
|
|
|
#define CmpObj_Check(x) (Py_TYPE(x) == &Component_Type || PyObject_TypeCheck((x), &Component_Type))
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
typedef struct ComponentObject {
|
|
|
|
PyObject_HEAD
|
|
|
|
Component ob_itself;
|
|
|
|
} ComponentObject;
|
|
|
|
|
|
|
|
PyObject *CmpObj_New(Component itself)
|
|
|
|
{
|
|
|
|
ComponentObject *it;
|
|
|
|
if (itself == NULL) {
|
2005-07-03 17:59:44 -03:00
|
|
|
/* XXXX Or should we return None? */
|
|
|
|
PyErr_SetString(Cm_Error,"No such component");
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-08-23 11:02:09 -03:00
|
|
|
it = PyObject_NEW(ComponentObject, &Component_Type);
|
|
|
|
if (it == NULL) return NULL;
|
|
|
|
it->ob_itself = itself;
|
|
|
|
return (PyObject *)it;
|
|
|
|
}
|
2005-07-03 17:59:44 -03:00
|
|
|
|
2001-09-04 19:19:18 -03:00
|
|
|
int CmpObj_Convert(PyObject *v, Component *p_itself)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
|
|
|
if ( v == Py_None ) {
|
2005-07-03 17:59:44 -03:00
|
|
|
*p_itself = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!CmpObj_Check(v))
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Component required");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*p_itself = ((ComponentObject *)v)->ob_itself;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CmpObj_dealloc(ComponentObject *self)
|
|
|
|
{
|
|
|
|
/* Cleanup of self->ob_itself goes here */
|
2007-12-18 22:45:37 -04:00
|
|
|
Py_TYPE(self)->tp_free((PyObject *)self);
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_UnregisterComponent(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef UnregisterComponent
|
|
|
|
PyMac_PRECHECK(UnregisterComponent);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = UnregisterComponent(_self->ob_itself);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_GetComponentInfo(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
ComponentDescription cd;
|
|
|
|
Handle componentName;
|
|
|
|
Handle componentInfo;
|
|
|
|
Handle componentIcon;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetComponentInfo
|
|
|
|
PyMac_PRECHECK(GetComponentInfo);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&O&",
|
|
|
|
ResObj_Convert, &componentName,
|
|
|
|
ResObj_Convert, &componentInfo,
|
|
|
|
ResObj_Convert, &componentIcon))
|
|
|
|
return NULL;
|
|
|
|
_err = GetComponentInfo(_self->ob_itself,
|
|
|
|
&cd,
|
|
|
|
componentName,
|
|
|
|
componentInfo,
|
|
|
|
componentIcon);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CmpDesc_New, &cd);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_OpenComponent(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ComponentInstance _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef OpenComponent
|
|
|
|
PyMac_PRECHECK(OpenComponent);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = OpenComponent(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CmpInstObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2001-12-16 16:18:40 -04:00
|
|
|
static PyObject *CmpObj_ResolveComponentAlias(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Component _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef ResolveComponentAlias
|
|
|
|
PyMac_PRECHECK(ResolveComponentAlias);
|
|
|
|
#endif
|
2001-12-16 16:18:40 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = ResolveComponentAlias(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CmpObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_GetComponentPublicIndString(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
Str255 theString;
|
|
|
|
short strListID;
|
|
|
|
short index;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetComponentPublicIndString
|
|
|
|
PyMac_PRECHECK(GetComponentPublicIndString);
|
|
|
|
#endif
|
2001-12-16 16:18:40 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&hh",
|
|
|
|
PyMac_GetStr255, theString,
|
|
|
|
&strListID,
|
|
|
|
&index))
|
|
|
|
return NULL;
|
|
|
|
_err = GetComponentPublicIndString(_self->ob_itself,
|
|
|
|
theString,
|
|
|
|
strListID,
|
|
|
|
index);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
static PyObject *CmpObj_GetComponentRefcon(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetComponentRefcon
|
|
|
|
PyMac_PRECHECK(GetComponentRefcon);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetComponentRefcon(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_SetComponentRefcon(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long theRefcon;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef SetComponentRefcon
|
|
|
|
PyMac_PRECHECK(SetComponentRefcon);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "l",
|
|
|
|
&theRefcon))
|
|
|
|
return NULL;
|
|
|
|
SetComponentRefcon(_self->ob_itself,
|
|
|
|
theRefcon);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_OpenComponentResFile(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
short _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef OpenComponentResFile
|
|
|
|
PyMac_PRECHECK(OpenComponentResFile);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = OpenComponentResFile(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_GetComponentResource(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
OSType resType;
|
|
|
|
short resID;
|
|
|
|
Handle theResource;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetComponentResource
|
|
|
|
PyMac_PRECHECK(GetComponentResource);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&h",
|
|
|
|
PyMac_GetOSType, &resType,
|
|
|
|
&resID))
|
|
|
|
return NULL;
|
|
|
|
_err = GetComponentResource(_self->ob_itself,
|
|
|
|
resType,
|
|
|
|
resID,
|
|
|
|
&theResource);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
ResObj_New, theResource);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_GetComponentIndString(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
Str255 theString;
|
|
|
|
short strListID;
|
|
|
|
short index;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetComponentIndString
|
|
|
|
PyMac_PRECHECK(GetComponentIndString);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&hh",
|
|
|
|
PyMac_GetStr255, theString,
|
|
|
|
&strListID,
|
|
|
|
&index))
|
|
|
|
return NULL;
|
|
|
|
_err = GetComponentIndString(_self->ob_itself,
|
|
|
|
theString,
|
|
|
|
strListID,
|
|
|
|
index);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_CountComponentInstances(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef CountComponentInstances
|
|
|
|
PyMac_PRECHECK(CountComponentInstances);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = CountComponentInstances(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_SetDefaultComponent(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
short flags;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef SetDefaultComponent
|
|
|
|
PyMac_PRECHECK(SetDefaultComponent);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&flags))
|
|
|
|
return NULL;
|
|
|
|
_err = SetDefaultComponent(_self->ob_itself,
|
|
|
|
flags);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_CaptureComponent(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Component _rv;
|
|
|
|
Component capturingComponent;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef CaptureComponent
|
|
|
|
PyMac_PRECHECK(CaptureComponent);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
CmpObj_Convert, &capturingComponent))
|
|
|
|
return NULL;
|
|
|
|
_rv = CaptureComponent(_self->ob_itself,
|
|
|
|
capturingComponent);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CmpObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_UncaptureComponent(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef UncaptureComponent
|
|
|
|
PyMac_PRECHECK(UncaptureComponent);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = UncaptureComponent(_self->ob_itself);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CmpObj_GetComponentIconSuite(ComponentObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
Handle iconSuite;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetComponentIconSuite
|
|
|
|
PyMac_PRECHECK(GetComponentIconSuite);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = GetComponentIconSuite(_self->ob_itself,
|
|
|
|
&iconSuite);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
ResObj_New, iconSuite);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef CmpObj_methods[] = {
|
|
|
|
{"UnregisterComponent", (PyCFunction)CmpObj_UnregisterComponent, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetComponentInfo", (PyCFunction)CmpObj_GetComponentInfo, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(Handle componentName, Handle componentInfo, Handle componentIcon) -> (ComponentDescription cd)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"OpenComponent", (PyCFunction)CmpObj_OpenComponent, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (ComponentInstance _rv)")},
|
2001-12-16 16:18:40 -04:00
|
|
|
{"ResolveComponentAlias", (PyCFunction)CmpObj_ResolveComponentAlias, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (Component _rv)")},
|
2001-12-16 16:18:40 -04:00
|
|
|
{"GetComponentPublicIndString", (PyCFunction)CmpObj_GetComponentPublicIndString, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(Str255 theString, short strListID, short index) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetComponentRefcon", (PyCFunction)CmpObj_GetComponentRefcon, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (long _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"SetComponentRefcon", (PyCFunction)CmpObj_SetComponentRefcon, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(long theRefcon) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"OpenComponentResFile", (PyCFunction)CmpObj_OpenComponentResFile, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (short _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetComponentResource", (PyCFunction)CmpObj_GetComponentResource, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(OSType resType, short resID) -> (Handle theResource)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetComponentIndString", (PyCFunction)CmpObj_GetComponentIndString, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(Str255 theString, short strListID, short index) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"CountComponentInstances", (PyCFunction)CmpObj_CountComponentInstances, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (long _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"SetDefaultComponent", (PyCFunction)CmpObj_SetDefaultComponent, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(short flags) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"CaptureComponent", (PyCFunction)CmpObj_CaptureComponent, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(Component capturingComponent) -> (Component _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"UncaptureComponent", (PyCFunction)CmpObj_UncaptureComponent, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetComponentIconSuite", (PyCFunction)CmpObj_GetComponentIconSuite, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (Handle iconSuite)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
2002-11-29 19:40:48 -04:00
|
|
|
#define CmpObj_getsetlist NULL
|
2001-08-23 11:02:09 -03:00
|
|
|
|
2002-12-03 19:40:22 -04:00
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
#define CmpObj_compare NULL
|
|
|
|
|
|
|
|
#define CmpObj_repr NULL
|
|
|
|
|
|
|
|
#define CmpObj_hash NULL
|
2002-12-03 19:40:22 -04:00
|
|
|
#define CmpObj_tp_init 0
|
|
|
|
|
|
|
|
#define CmpObj_tp_alloc PyType_GenericAlloc
|
|
|
|
|
2005-07-03 17:59:44 -03:00
|
|
|
static PyObject *CmpObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
|
2002-12-03 19:40:22 -04:00
|
|
|
{
|
2005-07-03 17:59:44 -03:00
|
|
|
PyObject *_self;
|
2002-12-03 19:40:22 -04:00
|
|
|
Component itself;
|
|
|
|
char *kw[] = {"itself", 0};
|
|
|
|
|
2005-07-03 17:59:44 -03:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CmpObj_Convert, &itself)) return NULL;
|
|
|
|
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
|
|
|
|
((ComponentObject *)_self)->ob_itself = itself;
|
|
|
|
return _self;
|
2002-12-03 19:40:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define CmpObj_tp_free PyObject_Del
|
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
PyTypeObject Component_Type = {
|
2007-07-22 11:41:55 -03:00
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
2001-12-08 14:02:58 -04:00
|
|
|
"_Cm.Component", /*tp_name*/
|
2001-08-23 11:02:09 -03:00
|
|
|
sizeof(ComponentObject), /*tp_basicsize*/
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
/* methods */
|
|
|
|
(destructor) CmpObj_dealloc, /*tp_dealloc*/
|
|
|
|
0, /*tp_print*/
|
2002-11-29 19:40:48 -04:00
|
|
|
(getattrfunc)0, /*tp_getattr*/
|
|
|
|
(setattrfunc)0, /*tp_setattr*/
|
2001-08-23 11:02:09 -03:00
|
|
|
(cmpfunc) CmpObj_compare, /*tp_compare*/
|
|
|
|
(reprfunc) CmpObj_repr, /*tp_repr*/
|
|
|
|
(PyNumberMethods *)0, /* tp_as_number */
|
|
|
|
(PySequenceMethods *)0, /* tp_as_sequence */
|
|
|
|
(PyMappingMethods *)0, /* tp_as_mapping */
|
|
|
|
(hashfunc) CmpObj_hash, /*tp_hash*/
|
2002-11-29 19:40:48 -04:00
|
|
|
0, /*tp_call*/
|
|
|
|
0, /*tp_str*/
|
|
|
|
PyObject_GenericGetAttr, /*tp_getattro*/
|
|
|
|
PyObject_GenericSetAttr, /*tp_setattro */
|
2002-12-03 19:40:22 -04:00
|
|
|
0, /*tp_as_buffer*/
|
|
|
|
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
|
|
|
|
0, /*tp_doc*/
|
|
|
|
0, /*tp_traverse*/
|
|
|
|
0, /*tp_clear*/
|
|
|
|
0, /*tp_richcompare*/
|
|
|
|
0, /*tp_weaklistoffset*/
|
|
|
|
0, /*tp_iter*/
|
|
|
|
0, /*tp_iternext*/
|
2002-11-29 19:40:48 -04:00
|
|
|
CmpObj_methods, /* tp_methods */
|
2002-12-03 19:40:22 -04:00
|
|
|
0, /*tp_members*/
|
2002-11-29 19:40:48 -04:00
|
|
|
CmpObj_getsetlist, /*tp_getset*/
|
2002-12-03 19:40:22 -04:00
|
|
|
0, /*tp_base*/
|
|
|
|
0, /*tp_dict*/
|
|
|
|
0, /*tp_descr_get*/
|
|
|
|
0, /*tp_descr_set*/
|
|
|
|
0, /*tp_dictoffset*/
|
|
|
|
CmpObj_tp_init, /* tp_init */
|
|
|
|
CmpObj_tp_alloc, /* tp_alloc */
|
|
|
|
CmpObj_tp_new, /* tp_new */
|
|
|
|
CmpObj_tp_free, /* tp_free */
|
2001-08-23 11:02:09 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ------------------- End object type Component -------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *Cm_RegisterComponentResource(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Component _rv;
|
|
|
|
ComponentResourceHandle cr;
|
|
|
|
short global;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef RegisterComponentResource
|
|
|
|
PyMac_PRECHECK(RegisterComponentResource);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&h",
|
|
|
|
ResObj_Convert, &cr,
|
|
|
|
&global))
|
|
|
|
return NULL;
|
|
|
|
_rv = RegisterComponentResource(cr,
|
|
|
|
global);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CmpObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Cm_FindNextComponent(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Component _rv;
|
|
|
|
Component aComponent;
|
|
|
|
ComponentDescription looking;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef FindNextComponent
|
|
|
|
PyMac_PRECHECK(FindNextComponent);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
CmpObj_Convert, &aComponent,
|
|
|
|
CmpDesc_Convert, &looking))
|
|
|
|
return NULL;
|
|
|
|
_rv = FindNextComponent(aComponent,
|
|
|
|
&looking);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CmpObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Cm_CountComponents(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long _rv;
|
|
|
|
ComponentDescription looking;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef CountComponents
|
|
|
|
PyMac_PRECHECK(CountComponents);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
CmpDesc_Convert, &looking))
|
|
|
|
return NULL;
|
|
|
|
_rv = CountComponents(&looking);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Cm_GetComponentListModSeed(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetComponentListModSeed
|
|
|
|
PyMac_PRECHECK(GetComponentListModSeed);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetComponentListModSeed();
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Cm_CloseComponentResFile(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
short refnum;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef CloseComponentResFile
|
|
|
|
PyMac_PRECHECK(CloseComponentResFile);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&refnum))
|
|
|
|
return NULL;
|
|
|
|
_err = CloseComponentResFile(refnum);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Cm_OpenDefaultComponent(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ComponentInstance _rv;
|
|
|
|
OSType componentType;
|
|
|
|
OSType componentSubType;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef OpenDefaultComponent
|
|
|
|
PyMac_PRECHECK(OpenDefaultComponent);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
PyMac_GetOSType, &componentType,
|
|
|
|
PyMac_GetOSType, &componentSubType))
|
|
|
|
return NULL;
|
|
|
|
_rv = OpenDefaultComponent(componentType,
|
|
|
|
componentSubType);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CmpInstObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Cm_RegisterComponentResourceFile(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long _rv;
|
|
|
|
short resRefNum;
|
|
|
|
short global;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef RegisterComponentResourceFile
|
|
|
|
PyMac_PRECHECK(RegisterComponentResourceFile);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hh",
|
|
|
|
&resRefNum,
|
|
|
|
&global))
|
|
|
|
return NULL;
|
|
|
|
_rv = RegisterComponentResourceFile(resRefNum,
|
|
|
|
global);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef Cm_methods[] = {
|
|
|
|
{"RegisterComponentResource", (PyCFunction)Cm_RegisterComponentResource, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(ComponentResourceHandle cr, short global) -> (Component _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"FindNextComponent", (PyCFunction)Cm_FindNextComponent, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(Component aComponent, ComponentDescription looking) -> (Component _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"CountComponents", (PyCFunction)Cm_CountComponents, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(ComponentDescription looking) -> (long _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetComponentListModSeed", (PyCFunction)Cm_GetComponentListModSeed, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (long _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"CloseComponentResFile", (PyCFunction)Cm_CloseComponentResFile, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(short refnum) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"OpenDefaultComponent", (PyCFunction)Cm_OpenDefaultComponent, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(OSType componentType, OSType componentSubType) -> (ComponentInstance _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"RegisterComponentResourceFile", (PyCFunction)Cm_RegisterComponentResourceFile, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(short resRefNum, short global) -> (long _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void init_Cm(void)
|
|
|
|
{
|
|
|
|
PyObject *m;
|
|
|
|
PyObject *d;
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-07-03 17:59:44 -03:00
|
|
|
PyMac_INIT_TOOLBOX_OBJECT_NEW(Component, CmpObj_New);
|
|
|
|
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Component, CmpObj_Convert);
|
|
|
|
PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, CmpInstObj_New);
|
|
|
|
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, CmpInstObj_Convert);
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
|
|
|
|
m = Py_InitModule("_Cm", Cm_methods);
|
|
|
|
d = PyModule_GetDict(m);
|
|
|
|
Cm_Error = PyMac_GetOSErrException();
|
|
|
|
if (Cm_Error == NULL ||
|
|
|
|
PyDict_SetItemString(d, "Error", Cm_Error) != 0)
|
|
|
|
return;
|
2007-12-18 22:45:37 -04:00
|
|
|
Py_TYPE(&ComponentInstance_Type) = &PyType_Type;
|
2002-12-23 19:16:25 -04:00
|
|
|
if (PyType_Ready(&ComponentInstance_Type) < 0) return;
|
2001-08-23 11:02:09 -03:00
|
|
|
Py_INCREF(&ComponentInstance_Type);
|
2002-12-03 19:40:22 -04:00
|
|
|
PyModule_AddObject(m, "ComponentInstance", (PyObject *)&ComponentInstance_Type);
|
|
|
|
/* Backward-compatible name */
|
|
|
|
Py_INCREF(&ComponentInstance_Type);
|
|
|
|
PyModule_AddObject(m, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type);
|
2007-12-18 22:45:37 -04:00
|
|
|
Py_TYPE(&Component_Type) = &PyType_Type;
|
2002-12-23 19:16:25 -04:00
|
|
|
if (PyType_Ready(&Component_Type) < 0) return;
|
2001-08-23 11:02:09 -03:00
|
|
|
Py_INCREF(&Component_Type);
|
2002-12-03 19:40:22 -04:00
|
|
|
PyModule_AddObject(m, "Component", (PyObject *)&Component_Type);
|
|
|
|
/* Backward-compatible name */
|
|
|
|
Py_INCREF(&Component_Type);
|
|
|
|
PyModule_AddObject(m, "ComponentType", (PyObject *)&Component_Type);
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ========================= End module _Cm ========================= */
|
|
|
|
|