Renamed the Mac toolbox modules to have an initial _ in their name.
This commit is contained in:
parent
3cbf6d9d6e
commit
50ecb0ad83
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,798 @@
|
|||
|
||||
/* =========================== Module _Cm =========================== */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
|
||||
|
||||
#include "macglue.h"
|
||||
#include "pymactoolbox.h"
|
||||
|
||||
/* Macro to test whether a weak-loaded CFM function exists */
|
||||
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
||||
PyErr_SetString(PyExc_NotImplementedError, \
|
||||
"Not available in this shared library/OS version"); \
|
||||
return NULL; \
|
||||
}} while(0)
|
||||
|
||||
|
||||
#ifdef WITHOUT_FRAMEWORKS
|
||||
#include <Components.h>
|
||||
#else
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
#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)
|
||||
{
|
||||
|
||||
return Py_BuildValue("O&O&O&ll",
|
||||
PyMac_BuildOSType, itself->componentType,
|
||||
PyMac_BuildOSType, itself->componentSubType,
|
||||
PyMac_BuildOSType, itself->componentManufacturer,
|
||||
itself->componentFlags, itself->componentFlagsMask);
|
||||
}
|
||||
|
||||
static int
|
||||
CmpDesc_Convert(PyObject *v, ComponentDescription *p_itself)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Cm_Error;
|
||||
|
||||
/* ----------------- Object type ComponentInstance ------------------ */
|
||||
|
||||
PyTypeObject ComponentInstance_Type;
|
||||
|
||||
#define CmpInstObj_Check(x) ((x)->ob_type == &ComponentInstance_Type)
|
||||
|
||||
typedef struct ComponentInstanceObject {
|
||||
PyObject_HEAD
|
||||
ComponentInstance ob_itself;
|
||||
} ComponentInstanceObject;
|
||||
|
||||
PyObject *CmpInstObj_New(ComponentInstance itself)
|
||||
{
|
||||
ComponentInstanceObject *it;
|
||||
if (itself == NULL) {
|
||||
PyErr_SetString(Cm_Error,"NULL ComponentInstance");
|
||||
return NULL;
|
||||
}
|
||||
it = PyObject_NEW(ComponentInstanceObject, &ComponentInstance_Type);
|
||||
if (it == NULL) return NULL;
|
||||
it->ob_itself = itself;
|
||||
return (PyObject *)it;
|
||||
}
|
||||
CmpInstObj_Convert(PyObject *v, ComponentInstance *p_itself)
|
||||
{
|
||||
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 */
|
||||
PyMem_DEL(self);
|
||||
}
|
||||
|
||||
static PyObject *CmpInstObj_CloseComponent(ComponentInstanceObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &theStorage))
|
||||
return NULL;
|
||||
SetComponentInstanceStorage(_self->ob_itself,
|
||||
theStorage);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *CmpInstObj_GetComponentInstanceA5(ComponentInstanceObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
long _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetComponentInstanceA5(_self->ob_itself);
|
||||
_res = Py_BuildValue("l",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *CmpInstObj_SetComponentInstanceA5(ComponentInstanceObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
long theA5;
|
||||
if (!PyArg_ParseTuple(_args, "l",
|
||||
&theA5))
|
||||
return NULL;
|
||||
SetComponentInstanceA5(_self->ob_itself,
|
||||
theA5);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *CmpInstObj_ComponentFunctionImplemented(ComponentInstanceObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
long _rv;
|
||||
short ftnNumber;
|
||||
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;
|
||||
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;
|
||||
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,
|
||||
"() -> None"},
|
||||
{"GetComponentInstanceError", (PyCFunction)CmpInstObj_GetComponentInstanceError, 1,
|
||||
"() -> None"},
|
||||
{"SetComponentInstanceError", (PyCFunction)CmpInstObj_SetComponentInstanceError, 1,
|
||||
"(OSErr theError) -> None"},
|
||||
{"GetComponentInstanceStorage", (PyCFunction)CmpInstObj_GetComponentInstanceStorage, 1,
|
||||
"() -> (Handle _rv)"},
|
||||
{"SetComponentInstanceStorage", (PyCFunction)CmpInstObj_SetComponentInstanceStorage, 1,
|
||||
"(Handle theStorage) -> None"},
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"GetComponentInstanceA5", (PyCFunction)CmpInstObj_GetComponentInstanceA5, 1,
|
||||
"() -> (long _rv)"},
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"SetComponentInstanceA5", (PyCFunction)CmpInstObj_SetComponentInstanceA5, 1,
|
||||
"(long theA5) -> None"},
|
||||
#endif
|
||||
{"ComponentFunctionImplemented", (PyCFunction)CmpInstObj_ComponentFunctionImplemented, 1,
|
||||
"(short ftnNumber) -> (long _rv)"},
|
||||
{"GetComponentVersion", (PyCFunction)CmpInstObj_GetComponentVersion, 1,
|
||||
"() -> (long _rv)"},
|
||||
{"ComponentSetTarget", (PyCFunction)CmpInstObj_ComponentSetTarget, 1,
|
||||
"(ComponentInstance target) -> (long _rv)"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
PyMethodChain CmpInstObj_chain = { CmpInstObj_methods, NULL };
|
||||
|
||||
static PyObject *CmpInstObj_getattr(ComponentInstanceObject *self, char *name)
|
||||
{
|
||||
return Py_FindMethodInChain(&CmpInstObj_chain, (PyObject *)self, name);
|
||||
}
|
||||
|
||||
#define CmpInstObj_setattr NULL
|
||||
|
||||
#define CmpInstObj_compare NULL
|
||||
|
||||
#define CmpInstObj_repr NULL
|
||||
|
||||
#define CmpInstObj_hash NULL
|
||||
|
||||
PyTypeObject ComponentInstance_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
"ComponentInstance", /*tp_name*/
|
||||
sizeof(ComponentInstanceObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor) CmpInstObj_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc) CmpInstObj_getattr, /*tp_getattr*/
|
||||
(setattrfunc) CmpInstObj_setattr, /*tp_setattr*/
|
||||
(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*/
|
||||
};
|
||||
|
||||
/* --------------- End object type ComponentInstance ---------------- */
|
||||
|
||||
|
||||
/* --------------------- Object type Component ---------------------- */
|
||||
|
||||
PyTypeObject Component_Type;
|
||||
|
||||
#define CmpObj_Check(x) ((x)->ob_type == &Component_Type)
|
||||
|
||||
typedef struct ComponentObject {
|
||||
PyObject_HEAD
|
||||
Component ob_itself;
|
||||
} ComponentObject;
|
||||
|
||||
PyObject *CmpObj_New(Component itself)
|
||||
{
|
||||
ComponentObject *it;
|
||||
if (itself == NULL) {
|
||||
/* XXXX Or should we return None? */
|
||||
PyErr_SetString(Cm_Error,"No such component");
|
||||
return NULL;
|
||||
}
|
||||
it = PyObject_NEW(ComponentObject, &Component_Type);
|
||||
if (it == NULL) return NULL;
|
||||
it->ob_itself = itself;
|
||||
return (PyObject *)it;
|
||||
}
|
||||
CmpObj_Convert(PyObject *v, Component *p_itself)
|
||||
{
|
||||
if ( v == Py_None ) {
|
||||
*p_itself = 0;
|
||||
return 1;
|
||||
}
|
||||
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 */
|
||||
PyMem_DEL(self);
|
||||
}
|
||||
|
||||
static PyObject *CmpObj_UnregisterComponent(ComponentObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
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;
|
||||
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;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = OpenComponent(_self->ob_itself);
|
||||
_res = Py_BuildValue("O&",
|
||||
CmpInstObj_New, _rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *CmpObj_GetComponentRefcon(ComponentObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
long _rv;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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_ResolveComponentAlias(ComponentObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Component _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = ResolveComponentAlias(_self->ob_itself);
|
||||
_res = Py_BuildValue("O&",
|
||||
CmpObj_New, _rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *CmpObj_CountComponentInstances(ComponentObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
long _rv;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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,
|
||||
"() -> None"},
|
||||
{"GetComponentInfo", (PyCFunction)CmpObj_GetComponentInfo, 1,
|
||||
"(Handle componentName, Handle componentInfo, Handle componentIcon) -> (ComponentDescription cd)"},
|
||||
{"OpenComponent", (PyCFunction)CmpObj_OpenComponent, 1,
|
||||
"() -> (ComponentInstance _rv)"},
|
||||
{"GetComponentRefcon", (PyCFunction)CmpObj_GetComponentRefcon, 1,
|
||||
"() -> (long _rv)"},
|
||||
{"SetComponentRefcon", (PyCFunction)CmpObj_SetComponentRefcon, 1,
|
||||
"(long theRefcon) -> None"},
|
||||
{"OpenComponentResFile", (PyCFunction)CmpObj_OpenComponentResFile, 1,
|
||||
"() -> (short _rv)"},
|
||||
{"GetComponentResource", (PyCFunction)CmpObj_GetComponentResource, 1,
|
||||
"(OSType resType, short resID) -> (Handle theResource)"},
|
||||
{"GetComponentIndString", (PyCFunction)CmpObj_GetComponentIndString, 1,
|
||||
"(Str255 theString, short strListID, short index) -> None"},
|
||||
{"ResolveComponentAlias", (PyCFunction)CmpObj_ResolveComponentAlias, 1,
|
||||
"() -> (Component _rv)"},
|
||||
{"CountComponentInstances", (PyCFunction)CmpObj_CountComponentInstances, 1,
|
||||
"() -> (long _rv)"},
|
||||
{"SetDefaultComponent", (PyCFunction)CmpObj_SetDefaultComponent, 1,
|
||||
"(short flags) -> None"},
|
||||
{"CaptureComponent", (PyCFunction)CmpObj_CaptureComponent, 1,
|
||||
"(Component capturingComponent) -> (Component _rv)"},
|
||||
{"UncaptureComponent", (PyCFunction)CmpObj_UncaptureComponent, 1,
|
||||
"() -> None"},
|
||||
{"GetComponentIconSuite", (PyCFunction)CmpObj_GetComponentIconSuite, 1,
|
||||
"() -> (Handle iconSuite)"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
PyMethodChain CmpObj_chain = { CmpObj_methods, NULL };
|
||||
|
||||
static PyObject *CmpObj_getattr(ComponentObject *self, char *name)
|
||||
{
|
||||
return Py_FindMethodInChain(&CmpObj_chain, (PyObject *)self, name);
|
||||
}
|
||||
|
||||
#define CmpObj_setattr NULL
|
||||
|
||||
#define CmpObj_compare NULL
|
||||
|
||||
#define CmpObj_repr NULL
|
||||
|
||||
#define CmpObj_hash NULL
|
||||
|
||||
PyTypeObject Component_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
"Component", /*tp_name*/
|
||||
sizeof(ComponentObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor) CmpObj_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc) CmpObj_getattr, /*tp_getattr*/
|
||||
(setattrfunc) CmpObj_setattr, /*tp_setattr*/
|
||||
(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*/
|
||||
};
|
||||
|
||||
/* ------------------- End object type Component -------------------- */
|
||||
|
||||
|
||||
static PyObject *Cm_RegisterComponentResource(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Component _rv;
|
||||
ComponentResourceHandle cr;
|
||||
short global;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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,
|
||||
"(ComponentResourceHandle cr, short global) -> (Component _rv)"},
|
||||
{"FindNextComponent", (PyCFunction)Cm_FindNextComponent, 1,
|
||||
"(Component aComponent, ComponentDescription looking) -> (Component _rv)"},
|
||||
{"CountComponents", (PyCFunction)Cm_CountComponents, 1,
|
||||
"(ComponentDescription looking) -> (long _rv)"},
|
||||
{"GetComponentListModSeed", (PyCFunction)Cm_GetComponentListModSeed, 1,
|
||||
"() -> (long _rv)"},
|
||||
{"CloseComponentResFile", (PyCFunction)Cm_CloseComponentResFile, 1,
|
||||
"(short refnum) -> None"},
|
||||
{"OpenDefaultComponent", (PyCFunction)Cm_OpenDefaultComponent, 1,
|
||||
"(OSType componentType, OSType componentSubType) -> (ComponentInstance _rv)"},
|
||||
{"RegisterComponentResourceFile", (PyCFunction)Cm_RegisterComponentResourceFile, 1,
|
||||
"(short resRefNum, short global) -> (long _rv)"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
void init_Cm(void)
|
||||
{
|
||||
PyObject *m;
|
||||
PyObject *d;
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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;
|
||||
ComponentInstance_Type.ob_type = &PyType_Type;
|
||||
Py_INCREF(&ComponentInstance_Type);
|
||||
if (PyDict_SetItemString(d, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type) != 0)
|
||||
Py_FatalError("can't initialize ComponentInstanceType");
|
||||
Component_Type.ob_type = &PyType_Type;
|
||||
Py_INCREF(&Component_Type);
|
||||
if (PyDict_SetItemString(d, "ComponentType", (PyObject *)&Component_Type) != 0)
|
||||
Py_FatalError("can't initialize ComponentType");
|
||||
}
|
||||
|
||||
/* ========================= End module _Cm ========================= */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,459 @@
|
|||
|
||||
/* ========================== Module _Evt =========================== */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
|
||||
|
||||
#include "macglue.h"
|
||||
#include "pymactoolbox.h"
|
||||
|
||||
/* Macro to test whether a weak-loaded CFM function exists */
|
||||
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
||||
PyErr_SetString(PyExc_NotImplementedError, \
|
||||
"Not available in this shared library/OS version"); \
|
||||
return NULL; \
|
||||
}} while(0)
|
||||
|
||||
|
||||
#ifdef WITHOUT_FRAMEWORKS
|
||||
#include <Events.h>
|
||||
#else
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
|
||||
static PyObject *Evt_Error;
|
||||
|
||||
static PyObject *Evt_GetMouse(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Point mouseLoc;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
GetMouse(&mouseLoc);
|
||||
_res = Py_BuildValue("O&",
|
||||
PyMac_BuildPoint, mouseLoc);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_Button(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = Button();
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_StillDown(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = StillDown();
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_WaitMouseUp(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = WaitMouseUp();
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_TickCount(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
UInt32 _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = TickCount();
|
||||
_res = Py_BuildValue("l",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_GetCaretTime(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
UInt32 _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetCaretTime();
|
||||
_res = Py_BuildValue("l",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_GetKeys(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
KeyMap theKeys__out__;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
GetKeys(theKeys__out__);
|
||||
_res = Py_BuildValue("s#",
|
||||
(char *)&theKeys__out__, (int)sizeof(KeyMap));
|
||||
theKeys__error__: ;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_GetDblTime(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
UInt32 _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetDblTime();
|
||||
_res = Py_BuildValue("l",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_SetEventMask(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
EventMask value;
|
||||
if (!PyArg_ParseTuple(_args, "H",
|
||||
&value))
|
||||
return NULL;
|
||||
SetEventMask(value);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_GetNextEvent(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
EventMask eventMask;
|
||||
EventRecord theEvent;
|
||||
if (!PyArg_ParseTuple(_args, "H",
|
||||
&eventMask))
|
||||
return NULL;
|
||||
_rv = GetNextEvent(eventMask,
|
||||
&theEvent);
|
||||
_res = Py_BuildValue("bO&",
|
||||
_rv,
|
||||
PyMac_BuildEventRecord, &theEvent);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_EventAvail(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
EventMask eventMask;
|
||||
EventRecord theEvent;
|
||||
if (!PyArg_ParseTuple(_args, "H",
|
||||
&eventMask))
|
||||
return NULL;
|
||||
_rv = EventAvail(eventMask,
|
||||
&theEvent);
|
||||
_res = Py_BuildValue("bO&",
|
||||
_rv,
|
||||
PyMac_BuildEventRecord, &theEvent);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Evt_PostEvent(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
EventKind eventNum;
|
||||
UInt32 eventMsg;
|
||||
if (!PyArg_ParseTuple(_args, "Hl",
|
||||
&eventNum,
|
||||
&eventMsg))
|
||||
return NULL;
|
||||
_err = PostEvent(eventNum,
|
||||
eventMsg);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Evt_OSEventAvail(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
EventMask mask;
|
||||
EventRecord theEvent;
|
||||
if (!PyArg_ParseTuple(_args, "H",
|
||||
&mask))
|
||||
return NULL;
|
||||
_rv = OSEventAvail(mask,
|
||||
&theEvent);
|
||||
_res = Py_BuildValue("bO&",
|
||||
_rv,
|
||||
PyMac_BuildEventRecord, &theEvent);
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Evt_GetOSEvent(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
EventMask mask;
|
||||
EventRecord theEvent;
|
||||
if (!PyArg_ParseTuple(_args, "H",
|
||||
&mask))
|
||||
return NULL;
|
||||
_rv = GetOSEvent(mask,
|
||||
&theEvent);
|
||||
_res = Py_BuildValue("bO&",
|
||||
_rv,
|
||||
PyMac_BuildEventRecord, &theEvent);
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *Evt_FlushEvents(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
EventMask whichMask;
|
||||
EventMask stopMask;
|
||||
if (!PyArg_ParseTuple(_args, "HH",
|
||||
&whichMask,
|
||||
&stopMask))
|
||||
return NULL;
|
||||
FlushEvents(whichMask,
|
||||
stopMask);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Evt_SystemClick(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
EventRecord theEvent;
|
||||
WindowPtr theWindow;
|
||||
if (!PyArg_ParseTuple(_args, "O&O&",
|
||||
PyMac_GetEventRecord, &theEvent,
|
||||
WinObj_Convert, &theWindow))
|
||||
return NULL;
|
||||
SystemClick(&theEvent,
|
||||
theWindow);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Evt_SystemTask(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
SystemTask();
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Evt_SystemEvent(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
EventRecord theEvent;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
PyMac_GetEventRecord, &theEvent))
|
||||
return NULL;
|
||||
_rv = SystemEvent(&theEvent);
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Evt_GetGlobalMouse(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Point globalMouse;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
GetGlobalMouse(&globalMouse);
|
||||
_res = Py_BuildValue("O&",
|
||||
PyMac_BuildPoint, globalMouse);
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Evt_GetCurrentKeyModifiers(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
UInt32 _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetCurrentKeyModifiers();
|
||||
_res = Py_BuildValue("l",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Evt_CheckEventQueueForUserCancel(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = CheckEventQueueForUserCancel();
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *Evt_WaitNextEvent(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
|
||||
Boolean _rv;
|
||||
EventMask eventMask;
|
||||
EventRecord theEvent;
|
||||
UInt32 sleep;
|
||||
Handle mouseregion = (Handle)0;
|
||||
|
||||
if (!PyArg_ParseTuple(_args, "Hl|O&",
|
||||
&eventMask,
|
||||
&sleep,
|
||||
OptResObj_Convert, &mouseregion))
|
||||
return NULL;
|
||||
_rv = WaitNextEvent(eventMask,
|
||||
&theEvent,
|
||||
sleep,
|
||||
(RgnHandle)mouseregion);
|
||||
_res = Py_BuildValue("bO&",
|
||||
_rv,
|
||||
PyMac_BuildEventRecord, &theEvent);
|
||||
return _res;
|
||||
|
||||
}
|
||||
|
||||
static PyMethodDef Evt_methods[] = {
|
||||
{"GetMouse", (PyCFunction)Evt_GetMouse, 1,
|
||||
"() -> (Point mouseLoc)"},
|
||||
{"Button", (PyCFunction)Evt_Button, 1,
|
||||
"() -> (Boolean _rv)"},
|
||||
{"StillDown", (PyCFunction)Evt_StillDown, 1,
|
||||
"() -> (Boolean _rv)"},
|
||||
{"WaitMouseUp", (PyCFunction)Evt_WaitMouseUp, 1,
|
||||
"() -> (Boolean _rv)"},
|
||||
{"TickCount", (PyCFunction)Evt_TickCount, 1,
|
||||
"() -> (UInt32 _rv)"},
|
||||
{"GetCaretTime", (PyCFunction)Evt_GetCaretTime, 1,
|
||||
"() -> (UInt32 _rv)"},
|
||||
{"GetKeys", (PyCFunction)Evt_GetKeys, 1,
|
||||
"() -> (KeyMap theKeys)"},
|
||||
{"GetDblTime", (PyCFunction)Evt_GetDblTime, 1,
|
||||
"() -> (UInt32 _rv)"},
|
||||
{"SetEventMask", (PyCFunction)Evt_SetEventMask, 1,
|
||||
"(EventMask value) -> None"},
|
||||
{"GetNextEvent", (PyCFunction)Evt_GetNextEvent, 1,
|
||||
"(EventMask eventMask) -> (Boolean _rv, EventRecord theEvent)"},
|
||||
{"EventAvail", (PyCFunction)Evt_EventAvail, 1,
|
||||
"(EventMask eventMask) -> (Boolean _rv, EventRecord theEvent)"},
|
||||
{"PostEvent", (PyCFunction)Evt_PostEvent, 1,
|
||||
"(EventKind eventNum, UInt32 eventMsg) -> None"},
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"OSEventAvail", (PyCFunction)Evt_OSEventAvail, 1,
|
||||
"(EventMask mask) -> (Boolean _rv, EventRecord theEvent)"},
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"GetOSEvent", (PyCFunction)Evt_GetOSEvent, 1,
|
||||
"(EventMask mask) -> (Boolean _rv, EventRecord theEvent)"},
|
||||
#endif
|
||||
{"FlushEvents", (PyCFunction)Evt_FlushEvents, 1,
|
||||
"(EventMask whichMask, EventMask stopMask) -> None"},
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"SystemClick", (PyCFunction)Evt_SystemClick, 1,
|
||||
"(EventRecord theEvent, WindowPtr theWindow) -> None"},
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"SystemTask", (PyCFunction)Evt_SystemTask, 1,
|
||||
"() -> None"},
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"SystemEvent", (PyCFunction)Evt_SystemEvent, 1,
|
||||
"(EventRecord theEvent) -> (Boolean _rv)"},
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
{"GetGlobalMouse", (PyCFunction)Evt_GetGlobalMouse, 1,
|
||||
"() -> (Point globalMouse)"},
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
{"GetCurrentKeyModifiers", (PyCFunction)Evt_GetCurrentKeyModifiers, 1,
|
||||
"() -> (UInt32 _rv)"},
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
{"CheckEventQueueForUserCancel", (PyCFunction)Evt_CheckEventQueueForUserCancel, 1,
|
||||
"() -> (Boolean _rv)"},
|
||||
#endif
|
||||
{"WaitNextEvent", (PyCFunction)Evt_WaitNextEvent, 1,
|
||||
"(EventMask eventMask, UInt32 sleep [,RegionHandle]) -> (Boolean _rv, EventRecord theEvent)"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
void init_Evt(void)
|
||||
{
|
||||
PyObject *m;
|
||||
PyObject *d;
|
||||
|
||||
|
||||
|
||||
|
||||
m = Py_InitModule("_Evt", Evt_methods);
|
||||
d = PyModule_GetDict(m);
|
||||
Evt_Error = PyMac_GetOSErrException();
|
||||
if (Evt_Error == NULL ||
|
||||
PyDict_SetItemString(d, "Error", Evt_Error) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* ======================== End module _Evt ========================= */
|
||||
|
|
@ -0,0 +1,359 @@
|
|||
|
||||
/* =========================== Module _Fm =========================== */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
|
||||
|
||||
#include "macglue.h"
|
||||
#include "pymactoolbox.h"
|
||||
|
||||
/* Macro to test whether a weak-loaded CFM function exists */
|
||||
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
||||
PyErr_SetString(PyExc_NotImplementedError, \
|
||||
"Not available in this shared library/OS version"); \
|
||||
return NULL; \
|
||||
}} while(0)
|
||||
|
||||
|
||||
#ifdef WITHOUT_FRAMEWORKS
|
||||
#include <Fonts.h>
|
||||
#else
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** Parse/generate ComponentDescriptor records
|
||||
*/
|
||||
static PyObject *
|
||||
FMRec_New(FMetricRec *itself)
|
||||
{
|
||||
|
||||
return Py_BuildValue("O&O&O&O&O&",
|
||||
PyMac_BuildFixed, itself->ascent,
|
||||
PyMac_BuildFixed, itself->descent,
|
||||
PyMac_BuildFixed, itself->leading,
|
||||
PyMac_BuildFixed, itself->widMax,
|
||||
ResObj_New, itself->wTabHandle);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Not needed... */
|
||||
static int
|
||||
FMRec_Convert(PyObject *v, FMetricRec *p_itself)
|
||||
{
|
||||
return PyArg_ParseTuple(v, "O&O&O&O&O&",
|
||||
PyMac_GetFixed, &itself->ascent,
|
||||
PyMac_GetFixed, &itself->descent,
|
||||
PyMac_GetFixed, &itself->leading,
|
||||
PyMac_GetFixed, &itself->widMax,
|
||||
ResObj_Convert, &itself->wTabHandle);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static PyObject *Fm_Error;
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Fm_InitFonts(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
InitFonts();
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *Fm_GetFontName(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
short familyID;
|
||||
Str255 name;
|
||||
if (!PyArg_ParseTuple(_args, "h",
|
||||
&familyID))
|
||||
return NULL;
|
||||
GetFontName(familyID,
|
||||
name);
|
||||
_res = Py_BuildValue("O&",
|
||||
PyMac_BuildStr255, name);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_GetFNum(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Str255 name;
|
||||
short familyID;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
PyMac_GetStr255, name))
|
||||
return NULL;
|
||||
GetFNum(name,
|
||||
&familyID);
|
||||
_res = Py_BuildValue("h",
|
||||
familyID);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_RealFont(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
short fontNum;
|
||||
short size;
|
||||
if (!PyArg_ParseTuple(_args, "hh",
|
||||
&fontNum,
|
||||
&size))
|
||||
return NULL;
|
||||
_rv = RealFont(fontNum,
|
||||
size);
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Fm_SetFontLock(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean lockFlag;
|
||||
if (!PyArg_ParseTuple(_args, "b",
|
||||
&lockFlag))
|
||||
return NULL;
|
||||
SetFontLock(lockFlag);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *Fm_SetFScaleDisable(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean fscaleDisable;
|
||||
if (!PyArg_ParseTuple(_args, "b",
|
||||
&fscaleDisable))
|
||||
return NULL;
|
||||
SetFScaleDisable(fscaleDisable);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_FontMetrics(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
FMetricRec theMetrics;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
FontMetrics(&theMetrics);
|
||||
_res = Py_BuildValue("O&",
|
||||
FMRec_New, &theMetrics);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_SetFractEnable(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean fractEnable;
|
||||
if (!PyArg_ParseTuple(_args, "b",
|
||||
&fractEnable))
|
||||
return NULL;
|
||||
SetFractEnable(fractEnable);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_GetDefFontSize(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
short _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetDefFontSize();
|
||||
_res = Py_BuildValue("h",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_IsOutline(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
Point numer;
|
||||
Point denom;
|
||||
if (!PyArg_ParseTuple(_args, "O&O&",
|
||||
PyMac_GetPoint, &numer,
|
||||
PyMac_GetPoint, &denom))
|
||||
return NULL;
|
||||
_rv = IsOutline(numer,
|
||||
denom);
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_SetOutlinePreferred(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean outlinePreferred;
|
||||
if (!PyArg_ParseTuple(_args, "b",
|
||||
&outlinePreferred))
|
||||
return NULL;
|
||||
SetOutlinePreferred(outlinePreferred);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_GetOutlinePreferred(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetOutlinePreferred();
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_SetPreserveGlyph(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean preserveGlyph;
|
||||
if (!PyArg_ParseTuple(_args, "b",
|
||||
&preserveGlyph))
|
||||
return NULL;
|
||||
SetPreserveGlyph(preserveGlyph);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_GetPreserveGlyph(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetPreserveGlyph();
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Fm_FlushFonts(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = FlushFonts();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *Fm_GetSysFont(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
short _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetSysFont();
|
||||
_res = Py_BuildValue("h",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Fm_GetAppFont(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
short _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetAppFont();
|
||||
_res = Py_BuildValue("h",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyMethodDef Fm_methods[] = {
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"InitFonts", (PyCFunction)Fm_InitFonts, 1,
|
||||
"() -> None"},
|
||||
#endif
|
||||
{"GetFontName", (PyCFunction)Fm_GetFontName, 1,
|
||||
"(short familyID) -> (Str255 name)"},
|
||||
{"GetFNum", (PyCFunction)Fm_GetFNum, 1,
|
||||
"(Str255 name) -> (short familyID)"},
|
||||
{"RealFont", (PyCFunction)Fm_RealFont, 1,
|
||||
"(short fontNum, short size) -> (Boolean _rv)"},
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"SetFontLock", (PyCFunction)Fm_SetFontLock, 1,
|
||||
"(Boolean lockFlag) -> None"},
|
||||
#endif
|
||||
{"SetFScaleDisable", (PyCFunction)Fm_SetFScaleDisable, 1,
|
||||
"(Boolean fscaleDisable) -> None"},
|
||||
{"FontMetrics", (PyCFunction)Fm_FontMetrics, 1,
|
||||
"() -> (FMetricRec theMetrics)"},
|
||||
{"SetFractEnable", (PyCFunction)Fm_SetFractEnable, 1,
|
||||
"(Boolean fractEnable) -> None"},
|
||||
{"GetDefFontSize", (PyCFunction)Fm_GetDefFontSize, 1,
|
||||
"() -> (short _rv)"},
|
||||
{"IsOutline", (PyCFunction)Fm_IsOutline, 1,
|
||||
"(Point numer, Point denom) -> (Boolean _rv)"},
|
||||
{"SetOutlinePreferred", (PyCFunction)Fm_SetOutlinePreferred, 1,
|
||||
"(Boolean outlinePreferred) -> None"},
|
||||
{"GetOutlinePreferred", (PyCFunction)Fm_GetOutlinePreferred, 1,
|
||||
"() -> (Boolean _rv)"},
|
||||
{"SetPreserveGlyph", (PyCFunction)Fm_SetPreserveGlyph, 1,
|
||||
"(Boolean preserveGlyph) -> None"},
|
||||
{"GetPreserveGlyph", (PyCFunction)Fm_GetPreserveGlyph, 1,
|
||||
"() -> (Boolean _rv)"},
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"FlushFonts", (PyCFunction)Fm_FlushFonts, 1,
|
||||
"() -> None"},
|
||||
#endif
|
||||
{"GetSysFont", (PyCFunction)Fm_GetSysFont, 1,
|
||||
"() -> (short _rv)"},
|
||||
{"GetAppFont", (PyCFunction)Fm_GetAppFont, 1,
|
||||
"() -> (short _rv)"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
void init_Fm(void)
|
||||
{
|
||||
PyObject *m;
|
||||
PyObject *d;
|
||||
|
||||
|
||||
|
||||
|
||||
m = Py_InitModule("_Fm", Fm_methods);
|
||||
d = PyModule_GetDict(m);
|
||||
Fm_Error = PyMac_GetOSErrException();
|
||||
if (Fm_Error == NULL ||
|
||||
PyDict_SetItemString(d, "Error", Fm_Error) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* ========================= End module _Fm ========================= */
|
||||
|
|
@ -0,0 +1,300 @@
|
|||
|
||||
/* ========================== Module _Help ========================== */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
|
||||
|
||||
#include "macglue.h"
|
||||
#include "pymactoolbox.h"
|
||||
|
||||
/* Macro to test whether a weak-loaded CFM function exists */
|
||||
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
||||
PyErr_SetString(PyExc_NotImplementedError, \
|
||||
"Not available in this shared library/OS version"); \
|
||||
return NULL; \
|
||||
}} while(0)
|
||||
|
||||
|
||||
#include <Balloons.h>
|
||||
|
||||
static PyObject *Help_Error;
|
||||
|
||||
static PyObject *Help_HMGetHelpMenuHandle(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
MenuHandle mh;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HMGetHelpMenuHandle(&mh);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&",
|
||||
MenuObj_New, mh);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMRemoveBalloon(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HMRemoveBalloon();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMIsBalloon(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = HMIsBalloon();
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMGetBalloons(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = HMGetBalloons();
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMSetBalloons(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
Boolean flag;
|
||||
if (!PyArg_ParseTuple(_args, "b",
|
||||
&flag))
|
||||
return NULL;
|
||||
_err = HMSetBalloons(flag);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMSetFont(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
SInt16 font;
|
||||
if (!PyArg_ParseTuple(_args, "h",
|
||||
&font))
|
||||
return NULL;
|
||||
_err = HMSetFont(font);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMSetFontSize(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
UInt16 fontSize;
|
||||
if (!PyArg_ParseTuple(_args, "H",
|
||||
&fontSize))
|
||||
return NULL;
|
||||
_err = HMSetFontSize(fontSize);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMGetFont(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
SInt16 font;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HMGetFont(&font);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("h",
|
||||
font);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMGetFontSize(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
UInt16 fontSize;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HMGetFontSize(&fontSize);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("H",
|
||||
fontSize);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMSetDialogResID(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
SInt16 resID;
|
||||
if (!PyArg_ParseTuple(_args, "h",
|
||||
&resID))
|
||||
return NULL;
|
||||
_err = HMSetDialogResID(resID);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMSetMenuResID(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
SInt16 menuID;
|
||||
SInt16 resID;
|
||||
if (!PyArg_ParseTuple(_args, "hh",
|
||||
&menuID,
|
||||
&resID))
|
||||
return NULL;
|
||||
_err = HMSetMenuResID(menuID,
|
||||
resID);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMScanTemplateItems(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
SInt16 whichID;
|
||||
SInt16 whichResFile;
|
||||
ResType whichType;
|
||||
if (!PyArg_ParseTuple(_args, "hhO&",
|
||||
&whichID,
|
||||
&whichResFile,
|
||||
PyMac_GetOSType, &whichType))
|
||||
return NULL;
|
||||
_err = HMScanTemplateItems(whichID,
|
||||
whichResFile,
|
||||
whichType);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMGetDialogResID(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
SInt16 resID;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HMGetDialogResID(&resID);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("h",
|
||||
resID);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMGetMenuResID(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
SInt16 menuID;
|
||||
SInt16 resID;
|
||||
if (!PyArg_ParseTuple(_args, "h",
|
||||
&menuID))
|
||||
return NULL;
|
||||
_err = HMGetMenuResID(menuID,
|
||||
&resID);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("h",
|
||||
resID);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Help_HMGetBalloonWindow(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSErr _err;
|
||||
WindowPtr window;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = HMGetBalloonWindow(&window);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&",
|
||||
WinObj_WhichWindow, window);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyMethodDef Help_methods[] = {
|
||||
{"HMGetHelpMenuHandle", (PyCFunction)Help_HMGetHelpMenuHandle, 1,
|
||||
"() -> (MenuHandle mh)"},
|
||||
{"HMRemoveBalloon", (PyCFunction)Help_HMRemoveBalloon, 1,
|
||||
"() -> None"},
|
||||
{"HMIsBalloon", (PyCFunction)Help_HMIsBalloon, 1,
|
||||
"() -> (Boolean _rv)"},
|
||||
{"HMGetBalloons", (PyCFunction)Help_HMGetBalloons, 1,
|
||||
"() -> (Boolean _rv)"},
|
||||
{"HMSetBalloons", (PyCFunction)Help_HMSetBalloons, 1,
|
||||
"(Boolean flag) -> None"},
|
||||
{"HMSetFont", (PyCFunction)Help_HMSetFont, 1,
|
||||
"(SInt16 font) -> None"},
|
||||
{"HMSetFontSize", (PyCFunction)Help_HMSetFontSize, 1,
|
||||
"(UInt16 fontSize) -> None"},
|
||||
{"HMGetFont", (PyCFunction)Help_HMGetFont, 1,
|
||||
"() -> (SInt16 font)"},
|
||||
{"HMGetFontSize", (PyCFunction)Help_HMGetFontSize, 1,
|
||||
"() -> (UInt16 fontSize)"},
|
||||
{"HMSetDialogResID", (PyCFunction)Help_HMSetDialogResID, 1,
|
||||
"(SInt16 resID) -> None"},
|
||||
{"HMSetMenuResID", (PyCFunction)Help_HMSetMenuResID, 1,
|
||||
"(SInt16 menuID, SInt16 resID) -> None"},
|
||||
{"HMScanTemplateItems", (PyCFunction)Help_HMScanTemplateItems, 1,
|
||||
"(SInt16 whichID, SInt16 whichResFile, ResType whichType) -> None"},
|
||||
{"HMGetDialogResID", (PyCFunction)Help_HMGetDialogResID, 1,
|
||||
"() -> (SInt16 resID)"},
|
||||
{"HMGetMenuResID", (PyCFunction)Help_HMGetMenuResID, 1,
|
||||
"(SInt16 menuID) -> (SInt16 resID)"},
|
||||
{"HMGetBalloonWindow", (PyCFunction)Help_HMGetBalloonWindow, 1,
|
||||
"() -> (WindowPtr window)"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
void init_Help(void)
|
||||
{
|
||||
PyObject *m;
|
||||
PyObject *d;
|
||||
|
||||
|
||||
|
||||
|
||||
m = Py_InitModule("_Help", Help_methods);
|
||||
d = PyModule_GetDict(m);
|
||||
Help_Error = PyMac_GetOSErrException();
|
||||
if (Help_Error == NULL ||
|
||||
PyDict_SetItemString(d, "Error", Help_Error) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* ======================== End module _Help ======================== */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,604 @@
|
|||
|
||||
/* ========================= Module _Qdoffs ========================= */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
|
||||
|
||||
#include "macglue.h"
|
||||
#include "pymactoolbox.h"
|
||||
|
||||
/* Macro to test whether a weak-loaded CFM function exists */
|
||||
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
||||
PyErr_SetString(PyExc_NotImplementedError, \
|
||||
"Not available in this shared library/OS version"); \
|
||||
return NULL; \
|
||||
}} while(0)
|
||||
|
||||
|
||||
#ifdef WITHOUT_FRAMEWORKS
|
||||
#include <QDOffscreen.h>
|
||||
#else
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_TOOLBOX_OBJECT_GLUE
|
||||
extern PyObject *_GWorldObj_New(GWorldPtr);
|
||||
extern int _GWorldObj_Convert(PyObject *, GWorldPtr *);
|
||||
|
||||
#define GWorldObj_New _GWorldObj_New
|
||||
#define GWorldObj_Convert _GWorldObj_Convert
|
||||
#endif
|
||||
|
||||
#define as_GrafPtr(gworld) ((GrafPtr)(gworld))
|
||||
|
||||
|
||||
static PyObject *Qdoffs_Error;
|
||||
|
||||
/* ----------------------- Object type GWorld ----------------------- */
|
||||
|
||||
PyTypeObject GWorld_Type;
|
||||
|
||||
#define GWorldObj_Check(x) ((x)->ob_type == &GWorld_Type)
|
||||
|
||||
typedef struct GWorldObject {
|
||||
PyObject_HEAD
|
||||
GWorldPtr ob_itself;
|
||||
} GWorldObject;
|
||||
|
||||
PyObject *GWorldObj_New(GWorldPtr itself)
|
||||
{
|
||||
GWorldObject *it;
|
||||
if (itself == NULL) return PyMac_Error(resNotFound);
|
||||
it = PyObject_NEW(GWorldObject, &GWorld_Type);
|
||||
if (it == NULL) return NULL;
|
||||
it->ob_itself = itself;
|
||||
return (PyObject *)it;
|
||||
}
|
||||
GWorldObj_Convert(PyObject *v, GWorldPtr *p_itself)
|
||||
{
|
||||
if (!GWorldObj_Check(v))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "GWorld required");
|
||||
return 0;
|
||||
}
|
||||
*p_itself = ((GWorldObject *)v)->ob_itself;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void GWorldObj_dealloc(GWorldObject *self)
|
||||
{
|
||||
DisposeGWorld(self->ob_itself);
|
||||
PyMem_DEL(self);
|
||||
}
|
||||
|
||||
static PyObject *GWorldObj_GetGWorldDevice(GWorldObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
GDHandle _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetGWorldDevice(_self->ob_itself);
|
||||
_res = Py_BuildValue("O&",
|
||||
ResObj_New, _rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *GWorldObj_GetGWorldPixMap(GWorldObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
PixMapHandle _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = GetGWorldPixMap(_self->ob_itself);
|
||||
_res = Py_BuildValue("O&",
|
||||
ResObj_New, _rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *GWorldObj_as_GrafPtr(GWorldObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
GrafPtr _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = as_GrafPtr(_self->ob_itself);
|
||||
_res = Py_BuildValue("O&",
|
||||
GrafObj_New, _rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyMethodDef GWorldObj_methods[] = {
|
||||
{"GetGWorldDevice", (PyCFunction)GWorldObj_GetGWorldDevice, 1,
|
||||
"() -> (GDHandle _rv)"},
|
||||
{"GetGWorldPixMap", (PyCFunction)GWorldObj_GetGWorldPixMap, 1,
|
||||
"() -> (PixMapHandle _rv)"},
|
||||
{"as_GrafPtr", (PyCFunction)GWorldObj_as_GrafPtr, 1,
|
||||
"() -> (GrafPtr _rv)"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
PyMethodChain GWorldObj_chain = { GWorldObj_methods, NULL };
|
||||
|
||||
static PyObject *GWorldObj_getattr(GWorldObject *self, char *name)
|
||||
{
|
||||
return Py_FindMethodInChain(&GWorldObj_chain, (PyObject *)self, name);
|
||||
}
|
||||
|
||||
#define GWorldObj_setattr NULL
|
||||
|
||||
#define GWorldObj_compare NULL
|
||||
|
||||
#define GWorldObj_repr NULL
|
||||
|
||||
#define GWorldObj_hash NULL
|
||||
|
||||
PyTypeObject GWorld_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
"GWorld", /*tp_name*/
|
||||
sizeof(GWorldObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor) GWorldObj_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc) GWorldObj_getattr, /*tp_getattr*/
|
||||
(setattrfunc) GWorldObj_setattr, /*tp_setattr*/
|
||||
(cmpfunc) GWorldObj_compare, /*tp_compare*/
|
||||
(reprfunc) GWorldObj_repr, /*tp_repr*/
|
||||
(PyNumberMethods *)0, /* tp_as_number */
|
||||
(PySequenceMethods *)0, /* tp_as_sequence */
|
||||
(PyMappingMethods *)0, /* tp_as_mapping */
|
||||
(hashfunc) GWorldObj_hash, /*tp_hash*/
|
||||
};
|
||||
|
||||
/* --------------------- End object type GWorld --------------------- */
|
||||
|
||||
|
||||
static PyObject *Qdoffs_NewGWorld(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
QDErr _err;
|
||||
GWorldPtr offscreenGWorld;
|
||||
short PixelDepth;
|
||||
Rect boundsRect;
|
||||
CTabHandle cTable;
|
||||
GDHandle aGDevice;
|
||||
GWorldFlags flags;
|
||||
if (!PyArg_ParseTuple(_args, "hO&O&O&l",
|
||||
&PixelDepth,
|
||||
PyMac_GetRect, &boundsRect,
|
||||
OptResObj_Convert, &cTable,
|
||||
OptResObj_Convert, &aGDevice,
|
||||
&flags))
|
||||
return NULL;
|
||||
_err = NewGWorld(&offscreenGWorld,
|
||||
PixelDepth,
|
||||
&boundsRect,
|
||||
cTable,
|
||||
aGDevice,
|
||||
flags);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&",
|
||||
GWorldObj_New, offscreenGWorld);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_LockPixels(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
PixMapHandle pm;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &pm))
|
||||
return NULL;
|
||||
_rv = LockPixels(pm);
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_UnlockPixels(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
PixMapHandle pm;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &pm))
|
||||
return NULL;
|
||||
UnlockPixels(pm);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_UpdateGWorld(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
GWorldFlags _rv;
|
||||
GWorldPtr offscreenGWorld;
|
||||
short pixelDepth;
|
||||
Rect boundsRect;
|
||||
CTabHandle cTable;
|
||||
GDHandle aGDevice;
|
||||
GWorldFlags flags;
|
||||
if (!PyArg_ParseTuple(_args, "hO&O&O&l",
|
||||
&pixelDepth,
|
||||
PyMac_GetRect, &boundsRect,
|
||||
OptResObj_Convert, &cTable,
|
||||
OptResObj_Convert, &aGDevice,
|
||||
&flags))
|
||||
return NULL;
|
||||
_rv = UpdateGWorld(&offscreenGWorld,
|
||||
pixelDepth,
|
||||
&boundsRect,
|
||||
cTable,
|
||||
aGDevice,
|
||||
flags);
|
||||
_res = Py_BuildValue("lO&",
|
||||
_rv,
|
||||
GWorldObj_New, offscreenGWorld);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_GetGWorld(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
CGrafPtr port;
|
||||
GDHandle gdh;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
GetGWorld(&port,
|
||||
&gdh);
|
||||
_res = Py_BuildValue("O&O&",
|
||||
GrafObj_New, port,
|
||||
ResObj_New, gdh);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_SetGWorld(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
CGrafPtr port;
|
||||
GDHandle gdh;
|
||||
if (!PyArg_ParseTuple(_args, "O&O&",
|
||||
GrafObj_Convert, &port,
|
||||
OptResObj_Convert, &gdh))
|
||||
return NULL;
|
||||
SetGWorld(port,
|
||||
gdh);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_CTabChanged(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
CTabHandle ctab;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
OptResObj_Convert, &ctab))
|
||||
return NULL;
|
||||
CTabChanged(ctab);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_PixPatChanged(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
PixPatHandle ppat;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &ppat))
|
||||
return NULL;
|
||||
PixPatChanged(ppat);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_PortChanged(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
GrafPtr port;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
GrafObj_Convert, &port))
|
||||
return NULL;
|
||||
PortChanged(port);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_GDeviceChanged(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
GDHandle gdh;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
OptResObj_Convert, &gdh))
|
||||
return NULL;
|
||||
GDeviceChanged(gdh);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_AllowPurgePixels(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
PixMapHandle pm;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &pm))
|
||||
return NULL;
|
||||
AllowPurgePixels(pm);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_NoPurgePixels(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
PixMapHandle pm;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &pm))
|
||||
return NULL;
|
||||
NoPurgePixels(pm);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_GetPixelsState(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
GWorldFlags _rv;
|
||||
PixMapHandle pm;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &pm))
|
||||
return NULL;
|
||||
_rv = GetPixelsState(pm);
|
||||
_res = Py_BuildValue("l",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_SetPixelsState(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
PixMapHandle pm;
|
||||
GWorldFlags state;
|
||||
if (!PyArg_ParseTuple(_args, "O&l",
|
||||
ResObj_Convert, &pm,
|
||||
&state))
|
||||
return NULL;
|
||||
SetPixelsState(pm,
|
||||
state);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_GetPixRowBytes(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
long _rv;
|
||||
PixMapHandle pm;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &pm))
|
||||
return NULL;
|
||||
_rv = GetPixRowBytes(pm);
|
||||
_res = Py_BuildValue("l",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_NewScreenBuffer(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
QDErr _err;
|
||||
Rect globalRect;
|
||||
Boolean purgeable;
|
||||
GDHandle gdh;
|
||||
PixMapHandle offscreenPixMap;
|
||||
if (!PyArg_ParseTuple(_args, "O&b",
|
||||
PyMac_GetRect, &globalRect,
|
||||
&purgeable))
|
||||
return NULL;
|
||||
_err = NewScreenBuffer(&globalRect,
|
||||
purgeable,
|
||||
&gdh,
|
||||
&offscreenPixMap);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&O&",
|
||||
ResObj_New, gdh,
|
||||
ResObj_New, offscreenPixMap);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_DisposeScreenBuffer(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
PixMapHandle offscreenPixMap;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &offscreenPixMap))
|
||||
return NULL;
|
||||
DisposeScreenBuffer(offscreenPixMap);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_QDDone(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
GrafPtr port;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
GrafObj_Convert, &port))
|
||||
return NULL;
|
||||
_rv = QDDone(port);
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_OffscreenVersion(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
long _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = OffscreenVersion();
|
||||
_res = Py_BuildValue("l",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_NewTempScreenBuffer(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
QDErr _err;
|
||||
Rect globalRect;
|
||||
Boolean purgeable;
|
||||
GDHandle gdh;
|
||||
PixMapHandle offscreenPixMap;
|
||||
if (!PyArg_ParseTuple(_args, "O&b",
|
||||
PyMac_GetRect, &globalRect,
|
||||
&purgeable))
|
||||
return NULL;
|
||||
_err = NewTempScreenBuffer(&globalRect,
|
||||
purgeable,
|
||||
&gdh,
|
||||
&offscreenPixMap);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_res = Py_BuildValue("O&O&",
|
||||
ResObj_New, gdh,
|
||||
ResObj_New, offscreenPixMap);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_PixMap32Bit(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
Boolean _rv;
|
||||
PixMapHandle pmHandle;
|
||||
if (!PyArg_ParseTuple(_args, "O&",
|
||||
ResObj_Convert, &pmHandle))
|
||||
return NULL;
|
||||
_rv = PixMap32Bit(pmHandle);
|
||||
_res = Py_BuildValue("b",
|
||||
_rv);
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_GetPixMapBytes(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
|
||||
PixMapHandle pm;
|
||||
int from, length;
|
||||
char *cp;
|
||||
|
||||
if ( !PyArg_ParseTuple(_args, "O&ii", ResObj_Convert, &pm, &from, &length) )
|
||||
return NULL;
|
||||
cp = GetPixBaseAddr(pm)+from;
|
||||
return PyString_FromStringAndSize(cp, length);
|
||||
|
||||
}
|
||||
|
||||
static PyObject *Qdoffs_PutPixMapBytes(PyObject *_self, PyObject *_args)
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
|
||||
PixMapHandle pm;
|
||||
int from, length;
|
||||
char *cp, *icp;
|
||||
|
||||
if ( !PyArg_ParseTuple(_args, "O&is#", ResObj_Convert, &pm, &from, &icp, &length) )
|
||||
return NULL;
|
||||
cp = GetPixBaseAddr(pm)+from;
|
||||
memcpy(cp, icp, length);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
|
||||
}
|
||||
|
||||
static PyMethodDef Qdoffs_methods[] = {
|
||||
{"NewGWorld", (PyCFunction)Qdoffs_NewGWorld, 1,
|
||||
"(short PixelDepth, Rect boundsRect, CTabHandle cTable, GDHandle aGDevice, GWorldFlags flags) -> (GWorldPtr offscreenGWorld)"},
|
||||
{"LockPixels", (PyCFunction)Qdoffs_LockPixels, 1,
|
||||
"(PixMapHandle pm) -> (Boolean _rv)"},
|
||||
{"UnlockPixels", (PyCFunction)Qdoffs_UnlockPixels, 1,
|
||||
"(PixMapHandle pm) -> None"},
|
||||
{"UpdateGWorld", (PyCFunction)Qdoffs_UpdateGWorld, 1,
|
||||
"(short pixelDepth, Rect boundsRect, CTabHandle cTable, GDHandle aGDevice, GWorldFlags flags) -> (GWorldFlags _rv, GWorldPtr offscreenGWorld)"},
|
||||
{"GetGWorld", (PyCFunction)Qdoffs_GetGWorld, 1,
|
||||
"() -> (CGrafPtr port, GDHandle gdh)"},
|
||||
{"SetGWorld", (PyCFunction)Qdoffs_SetGWorld, 1,
|
||||
"(CGrafPtr port, GDHandle gdh) -> None"},
|
||||
{"CTabChanged", (PyCFunction)Qdoffs_CTabChanged, 1,
|
||||
"(CTabHandle ctab) -> None"},
|
||||
{"PixPatChanged", (PyCFunction)Qdoffs_PixPatChanged, 1,
|
||||
"(PixPatHandle ppat) -> None"},
|
||||
{"PortChanged", (PyCFunction)Qdoffs_PortChanged, 1,
|
||||
"(GrafPtr port) -> None"},
|
||||
{"GDeviceChanged", (PyCFunction)Qdoffs_GDeviceChanged, 1,
|
||||
"(GDHandle gdh) -> None"},
|
||||
{"AllowPurgePixels", (PyCFunction)Qdoffs_AllowPurgePixels, 1,
|
||||
"(PixMapHandle pm) -> None"},
|
||||
{"NoPurgePixels", (PyCFunction)Qdoffs_NoPurgePixels, 1,
|
||||
"(PixMapHandle pm) -> None"},
|
||||
{"GetPixelsState", (PyCFunction)Qdoffs_GetPixelsState, 1,
|
||||
"(PixMapHandle pm) -> (GWorldFlags _rv)"},
|
||||
{"SetPixelsState", (PyCFunction)Qdoffs_SetPixelsState, 1,
|
||||
"(PixMapHandle pm, GWorldFlags state) -> None"},
|
||||
{"GetPixRowBytes", (PyCFunction)Qdoffs_GetPixRowBytes, 1,
|
||||
"(PixMapHandle pm) -> (long _rv)"},
|
||||
{"NewScreenBuffer", (PyCFunction)Qdoffs_NewScreenBuffer, 1,
|
||||
"(Rect globalRect, Boolean purgeable) -> (GDHandle gdh, PixMapHandle offscreenPixMap)"},
|
||||
{"DisposeScreenBuffer", (PyCFunction)Qdoffs_DisposeScreenBuffer, 1,
|
||||
"(PixMapHandle offscreenPixMap) -> None"},
|
||||
{"QDDone", (PyCFunction)Qdoffs_QDDone, 1,
|
||||
"(GrafPtr port) -> (Boolean _rv)"},
|
||||
{"OffscreenVersion", (PyCFunction)Qdoffs_OffscreenVersion, 1,
|
||||
"() -> (long _rv)"},
|
||||
{"NewTempScreenBuffer", (PyCFunction)Qdoffs_NewTempScreenBuffer, 1,
|
||||
"(Rect globalRect, Boolean purgeable) -> (GDHandle gdh, PixMapHandle offscreenPixMap)"},
|
||||
{"PixMap32Bit", (PyCFunction)Qdoffs_PixMap32Bit, 1,
|
||||
"(PixMapHandle pmHandle) -> (Boolean _rv)"},
|
||||
{"GetPixMapBytes", (PyCFunction)Qdoffs_GetPixMapBytes, 1,
|
||||
"(pixmap, int start, int size) -> string. Return bytes from the pixmap"},
|
||||
{"PutPixMapBytes", (PyCFunction)Qdoffs_PutPixMapBytes, 1,
|
||||
"(pixmap, int start, string data). Store bytes into the pixmap"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
void init_Qdoffs(void)
|
||||
{
|
||||
PyObject *m;
|
||||
PyObject *d;
|
||||
|
||||
|
||||
|
||||
PyMac_INIT_TOOLBOX_OBJECT_NEW(GWorldPtr, GWorldObj_New);
|
||||
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert);
|
||||
|
||||
|
||||
m = Py_InitModule("_Qdoffs", Qdoffs_methods);
|
||||
d = PyModule_GetDict(m);
|
||||
Qdoffs_Error = PyMac_GetOSErrException();
|
||||
if (Qdoffs_Error == NULL ||
|
||||
PyDict_SetItemString(d, "Error", Qdoffs_Error) != 0)
|
||||
return;
|
||||
GWorld_Type.ob_type = &PyType_Type;
|
||||
Py_INCREF(&GWorld_Type);
|
||||
if (PyDict_SetItemString(d, "GWorldType", (PyObject *)&GWorld_Type) != 0)
|
||||
Py_FatalError("can't initialize GWorldType");
|
||||
}
|
||||
|
||||
/* ======================= End module _Qdoffs ======================= */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,260 @@
|
|||
|
||||
/* ========================== Module Scrap ========================== */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
|
||||
|
||||
#include "macglue.h"
|
||||
#include "pymactoolbox.h"
|
||||
|
||||
#ifdef WITHOUT_FRAMEWORKS
|
||||
#include <Scrap.h>
|
||||
#else
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
/*
|
||||
** Generate ScrapInfo records
|
||||
*/
|
||||
static PyObject *
|
||||
SCRRec_New(itself)
|
||||
ScrapStuff *itself;
|
||||
{
|
||||
|
||||
return Py_BuildValue("lO&hhO&", itself->scrapSize,
|
||||
ResObj_New, itself->scrapHandle, itself->scrapCount, itself->scrapState,
|
||||
PyMac_BuildStr255, itself->scrapName);
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject *Scrap_Error;
|
||||
|
||||
static PyObject *Scrap_LoadScrap(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = LoadScrap();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Scrap_UnloadScrap(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = UnloadScrap();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Scrap_InfoScrap(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
ScrapStuffPtr _rv;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_rv = InfoScrap();
|
||||
_res = Py_BuildValue("O&",
|
||||
SCRRec_New, _rv);
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Scrap_GetScrap(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
long _rv;
|
||||
Handle destination;
|
||||
ScrapFlavorType flavorType;
|
||||
SInt32 offset;
|
||||
if (!PyArg_ParseTuple(_args, "O&O&",
|
||||
ResObj_Convert, &destination,
|
||||
PyMac_GetOSType, &flavorType))
|
||||
return NULL;
|
||||
_rv = GetScrap(destination,
|
||||
flavorType,
|
||||
&offset);
|
||||
_res = Py_BuildValue("ll",
|
||||
_rv,
|
||||
offset);
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static PyObject *Scrap_ZeroScrap(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
#if TARGET_API_MAC_CARBON
|
||||
{
|
||||
ScrapRef scrap;
|
||||
|
||||
_err = ClearCurrentScrap();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_err = GetCurrentScrap(&scrap);
|
||||
}
|
||||
#else
|
||||
_err = ZeroScrap();
|
||||
#endif
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
|
||||
static PyObject *Scrap_PutScrap(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
SInt32 sourceBufferByteCount;
|
||||
ScrapFlavorType flavorType;
|
||||
char *sourceBuffer__in__;
|
||||
int sourceBuffer__len__;
|
||||
int sourceBuffer__in_len__;
|
||||
#if TARGET_API_MAC_CARBON
|
||||
ScrapRef scrap;
|
||||
#endif
|
||||
|
||||
if (!PyArg_ParseTuple(_args, "O&s#",
|
||||
PyMac_GetOSType, &flavorType,
|
||||
&sourceBuffer__in__, &sourceBuffer__in_len__))
|
||||
return NULL;
|
||||
sourceBufferByteCount = sourceBuffer__in_len__;
|
||||
sourceBuffer__len__ = sourceBuffer__in_len__;
|
||||
#if TARGET_API_MAC_CARBON
|
||||
_err = GetCurrentScrap(&scrap);
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
_err = PutScrapFlavor(scrap, flavorType, 0, sourceBufferByteCount, sourceBuffer__in__);
|
||||
#else
|
||||
_err = PutScrap(sourceBufferByteCount,
|
||||
flavorType,
|
||||
sourceBuffer__in__);
|
||||
#endif
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
sourceBuffer__error__: ;
|
||||
return _res;
|
||||
}
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Scrap_ClearCurrentScrap(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = ClearCurrentScrap();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
|
||||
static PyObject *Scrap_CallInScrapPromises(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
OSStatus _err;
|
||||
if (!PyArg_ParseTuple(_args, ""))
|
||||
return NULL;
|
||||
_err = CallInScrapPromises();
|
||||
if (_err != noErr) return PyMac_Error(_err);
|
||||
Py_INCREF(Py_None);
|
||||
_res = Py_None;
|
||||
return _res;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyMethodDef Scrap_methods[] = {
|
||||
{"LoadScrap", (PyCFunction)Scrap_LoadScrap, 1,
|
||||
"() -> None"},
|
||||
{"UnloadScrap", (PyCFunction)Scrap_UnloadScrap, 1,
|
||||
"() -> None"},
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"InfoScrap", (PyCFunction)Scrap_InfoScrap, 1,
|
||||
"() -> (ScrapStuffPtr _rv)"},
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
{"GetScrap", (PyCFunction)Scrap_GetScrap, 1,
|
||||
"(Handle destination, ScrapFlavorType flavorType) -> (long _rv, SInt32 offset)"},
|
||||
#endif
|
||||
|
||||
{"ZeroScrap", (PyCFunction)Scrap_ZeroScrap, 1,
|
||||
"() -> None"},
|
||||
|
||||
{"PutScrap", (PyCFunction)Scrap_PutScrap, 1,
|
||||
"(ScrapFlavorType flavorType, Buffer sourceBuffer) -> None"},
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
{"ClearCurrentScrap", (PyCFunction)Scrap_ClearCurrentScrap, 1,
|
||||
"() -> None"},
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
{"CallInScrapPromises", (PyCFunction)Scrap_CallInScrapPromises, 1,
|
||||
"() -> None"},
|
||||
#endif
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
void init_Scrap()
|
||||
{
|
||||
PyObject *m;
|
||||
PyObject *d;
|
||||
|
||||
|
||||
|
||||
|
||||
m = Py_InitModule("_Scrap", Scrap_methods);
|
||||
d = PyModule_GetDict(m);
|
||||
Scrap_Error = PyMac_GetOSErrException();
|
||||
if (Scrap_Error == NULL ||
|
||||
PyDict_SetItemString(d, "Error", Scrap_Error) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* ======================== End module Scrap ======================== */
|
||||
|
|
@ -0,0 +1,513 @@
|
|||
/***********************************************************
|
||||
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
|
||||
The Netherlands.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the names of Stichting Mathematisch
|
||||
Centrum or CWI or Corporation for National Research Initiatives or
|
||||
CNRI not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
While CWI is the initial source for this software, a modified version
|
||||
is made available by the Corporation for National Research Initiatives
|
||||
(CNRI) at the Internet address ftp://ftp.python.org.
|
||||
|
||||
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
|
||||
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
******************************************************************/
|
||||
|
||||
#include "Python.h"
|
||||
#include "macglue.h"
|
||||
#include "pymactoolbox.h"
|
||||
#include <Sound.h>
|
||||
|
||||
#pragma options align=mac68k
|
||||
struct SampleRateAvailable_arg {
|
||||
short numrates;
|
||||
Handle rates;
|
||||
};
|
||||
|
||||
struct SampleSizeAvailable_arg {
|
||||
short numsizes;
|
||||
Handle sizes;
|
||||
};
|
||||
|
||||
#pragma options align=reset
|
||||
|
||||
static PyObject *ErrorObject;
|
||||
|
||||
|
||||
/* Convert Python object to unsigned Fixed */
|
||||
static int
|
||||
PyMac_GetUFixed(PyObject *v, Fixed *f)
|
||||
{
|
||||
double d;
|
||||
unsigned long uns;
|
||||
|
||||
if( !PyArg_Parse(v, "d", &d))
|
||||
return 0;
|
||||
uns = (unsigned long)(d * 0x10000);
|
||||
*f = (Fixed)uns;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Convert a Point to a Python object */
|
||||
static PyObject *
|
||||
PyMac_BuildUFixed(Fixed f)
|
||||
{
|
||||
double d;
|
||||
unsigned long funs;
|
||||
|
||||
funs = (unsigned long)f;
|
||||
|
||||
d = funs;
|
||||
d = d / 0x10000;
|
||||
return Py_BuildValue("d", d);
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------- */
|
||||
|
||||
static char sndih_getChannelAvailable__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_getChannelAvailable(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short nchannel;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &inRefNum))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBGetDeviceInfo(inRefNum, siChannelAvailable, (Ptr)&nchannel)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
return Py_BuildValue("h", nchannel);
|
||||
}
|
||||
|
||||
static char sndih_getNumberChannels__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_getNumberChannels(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short nchannel;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &inRefNum))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBGetDeviceInfo(inRefNum, siNumberChannels, (Ptr)&nchannel)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
return Py_BuildValue("h", nchannel);
|
||||
}
|
||||
|
||||
static char sndih_setNumberChannels__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_setNumberChannels(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short nchannel;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "lh", &inRefNum, &nchannel))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBSetDeviceInfo(inRefNum, siNumberChannels, (Ptr)&nchannel)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char sndih_getContinuous__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_getContinuous(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short onoff;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &inRefNum))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBGetDeviceInfo(inRefNum, siContinuous, (Ptr)&onoff)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
return Py_BuildValue("h", onoff);
|
||||
}
|
||||
|
||||
static char sndih_setContinuous__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_setContinuous(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short onoff;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "lh", &inRefNum, &onoff))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBSetDeviceInfo(inRefNum, siContinuous, (Ptr)&onoff)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char sndih_getInputSourceNames__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_getInputSourceNames(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
Handle names;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &inRefNum))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBGetDeviceInfo(inRefNum, siInputSourceNames, (Ptr)&names)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
return Py_BuildValue("O&", ResObj_New, names);
|
||||
}
|
||||
|
||||
static char sndih_getInputSource__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_getInputSource(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short source;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &inRefNum))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBGetDeviceInfo(inRefNum, siInputSource, (Ptr)&source)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
return Py_BuildValue("h", source);
|
||||
}
|
||||
|
||||
static char sndih_setInputSource__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_setInputSource(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short source;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "lh", &inRefNum, &source))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBSetDeviceInfo(inRefNum, siInputSource, (Ptr)&source)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char sndih_getPlayThruOnOff__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_getPlayThruOnOff(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short onoff;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &inRefNum))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBGetDeviceInfo(inRefNum, siPlayThruOnOff, (Ptr)&onoff)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
return Py_BuildValue("h", onoff);
|
||||
}
|
||||
|
||||
static char sndih_setPlayThruOnOff__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_setPlayThruOnOff(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short onoff;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "lh", &inRefNum, &onoff))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBSetDeviceInfo(inRefNum, siPlayThruOnOff, (Ptr)&onoff)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char sndih_getSampleRate__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_getSampleRate(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
Fixed sample_rate;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &inRefNum))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBGetDeviceInfo(inRefNum, siSampleRate, (Ptr)&sample_rate)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
return Py_BuildValue("O&", PyMac_BuildUFixed, sample_rate);
|
||||
}
|
||||
|
||||
static char sndih_setSampleRate__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_setSampleRate(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
Fixed sample_rate;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "lO&", &inRefNum, PyMac_GetUFixed, &sample_rate))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBSetDeviceInfo(inRefNum, siSampleRate, (Ptr)&sample_rate)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char sndih_getSampleSize__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_getSampleSize(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short bits;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &inRefNum))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBGetDeviceInfo(inRefNum, siSampleSize, (Ptr)&bits)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
return Py_BuildValue("h", bits);
|
||||
}
|
||||
|
||||
static char sndih_setSampleSize__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_setSampleSize(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
short size;
|
||||
OSErr err;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "lh", &inRefNum, &size))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBSetDeviceInfo(inRefNum, siSampleSize, (Ptr)&size)) != noErr )
|
||||
return PyMac_Error(err);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char sndih_getSampleSizeAvailable__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_getSampleSizeAvailable(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
struct SampleSizeAvailable_arg arg;
|
||||
OSErr err;
|
||||
PyObject *rsizes;
|
||||
short *fsizes;
|
||||
int i;
|
||||
|
||||
arg.sizes = NULL;
|
||||
rsizes = NULL;
|
||||
if (!PyArg_ParseTuple(args, "l", &inRefNum))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBGetDeviceInfo(inRefNum, siSampleSizeAvailable, (Ptr)&arg)) != noErr ) {
|
||||
return PyMac_Error(err);
|
||||
}
|
||||
fsizes = (short *)*(arg.sizes);
|
||||
/* Handle contains a list of rates */
|
||||
if( (rsizes = PyTuple_New(arg.numsizes)) == NULL)
|
||||
return NULL;
|
||||
for( i=0; i<arg.numsizes; i++ )
|
||||
PyTuple_SetItem(rsizes, i, PyInt_FromLong((long)fsizes[i]));
|
||||
return rsizes;
|
||||
}
|
||||
|
||||
static char sndih_getSampleRateAvailable__doc__[] =
|
||||
""
|
||||
;
|
||||
|
||||
static PyObject *
|
||||
sndih_getSampleRateAvailable(self, args)
|
||||
PyObject *self; /* Not used */
|
||||
PyObject *args;
|
||||
{
|
||||
long inRefNum;
|
||||
struct SampleRateAvailable_arg arg;
|
||||
OSErr err;
|
||||
PyObject *rrates, *obj;
|
||||
Fixed *frates;
|
||||
int i;
|
||||
|
||||
arg.rates = NULL;
|
||||
rrates = NULL;
|
||||
if (!PyArg_ParseTuple(args, "l", &inRefNum))
|
||||
return NULL;
|
||||
|
||||
if( (err=SPBGetDeviceInfo(inRefNum, siSampleRateAvailable, (Ptr)&arg)) != noErr ) {
|
||||
return PyMac_Error(err);
|
||||
}
|
||||
frates = (Fixed *)*(arg.rates);
|
||||
if( arg.numrates == 0 ) {
|
||||
/* The handle contains upper and lowerbound */
|
||||
rrates = Py_BuildValue("O&O&", frates[0], frates[1]);
|
||||
if (rrates == NULL) return NULL;
|
||||
} else {
|
||||
/* Handle contains a list of rates */
|
||||
if( (rrates = PyTuple_New(arg.numrates)) == NULL)
|
||||
return NULL;
|
||||
for( i=0; i<arg.numrates; i++ ) {
|
||||
if( (obj = Py_BuildValue("O&", PyMac_BuildUFixed, frates[i]))==NULL)
|
||||
goto out;
|
||||
PyTuple_SetItem(rrates, i, obj);
|
||||
}
|
||||
}
|
||||
return Py_BuildValue("hO", arg.numrates, rrates);
|
||||
out:
|
||||
Py_XDECREF(rrates);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* List of methods defined in the module */
|
||||
|
||||
static struct PyMethodDef sndih_methods[] = {
|
||||
{"getChannelAvailable", (PyCFunction)sndih_getChannelAvailable, METH_VARARGS, sndih_getChannelAvailable__doc__},
|
||||
{"getNumberChannels", (PyCFunction)sndih_getNumberChannels, METH_VARARGS, sndih_getNumberChannels__doc__},
|
||||
{"setNumberChannels", (PyCFunction)sndih_setNumberChannels, METH_VARARGS, sndih_setNumberChannels__doc__},
|
||||
{"getContinuous", (PyCFunction)sndih_getContinuous, METH_VARARGS, sndih_getContinuous__doc__},
|
||||
{"setContinuous", (PyCFunction)sndih_setContinuous, METH_VARARGS, sndih_setContinuous__doc__},
|
||||
{"getInputSourceNames", (PyCFunction)sndih_getInputSourceNames, METH_VARARGS, sndih_getInputSourceNames__doc__},
|
||||
{"getInputSource", (PyCFunction)sndih_getInputSource, METH_VARARGS, sndih_getInputSource__doc__},
|
||||
{"setInputSource", (PyCFunction)sndih_setInputSource, METH_VARARGS, sndih_setInputSource__doc__},
|
||||
{"getPlayThruOnOff", (PyCFunction)sndih_getPlayThruOnOff, METH_VARARGS, sndih_getPlayThruOnOff__doc__},
|
||||
{"setPlayThruOnOff", (PyCFunction)sndih_setPlayThruOnOff, METH_VARARGS, sndih_setPlayThruOnOff__doc__},
|
||||
{"getSampleRate", (PyCFunction)sndih_getSampleRate, METH_VARARGS, sndih_getSampleRate__doc__},
|
||||
{"setSampleRate", (PyCFunction)sndih_setSampleRate, METH_VARARGS, sndih_setSampleRate__doc__},
|
||||
{"getSampleSize", (PyCFunction)sndih_getSampleSize, METH_VARARGS, sndih_getSampleSize__doc__},
|
||||
{"setSampleSize", (PyCFunction)sndih_setSampleSize, METH_VARARGS, sndih_setSampleSize__doc__},
|
||||
{"getSampleSizeAvailable", (PyCFunction)sndih_getSampleSizeAvailable, METH_VARARGS, sndih_getSampleSizeAvailable__doc__},
|
||||
{"getSampleRateAvailable", (PyCFunction)sndih_getSampleRateAvailable, METH_VARARGS, sndih_getSampleRateAvailable__doc__},
|
||||
|
||||
{NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
||||
/* Initialization function for the module (*must* be called initSndihooks) */
|
||||
|
||||
static char Sndihooks_module_documentation[] =
|
||||
""
|
||||
;
|
||||
|
||||
void
|
||||
init_Sndihooks()
|
||||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
/* Create the module and add the functions */
|
||||
m = Py_InitModule4("_Sndihooks", sndih_methods,
|
||||
Sndihooks_module_documentation,
|
||||
(PyObject*)NULL,PYTHON_API_VERSION);
|
||||
|
||||
/* Add some symbolic constants to the module */
|
||||
d = PyModule_GetDict(m);
|
||||
ErrorObject = PyString_FromString("Sndihooks.error");
|
||||
PyDict_SetItemString(d, "error", ErrorObject);
|
||||
|
||||
/* XXXX Add constants here */
|
||||
|
||||
/* Check for errors */
|
||||
if (PyErr_Occurred())
|
||||
Py_FatalError("can't initialize module Sndihooks");
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue