item = PyString_FromString(pvs[i].value.ptr); PyMem_DEL(pvs[i].value.ptr); break; case AL_MATRIX_VAL: /* XXXX this is not right */ pvs[i].sizeOut *= pvs[i].size2Out; /* fall through */ case AL_SET_VAL: case AL_VECTOR_VAL: item = PyList_New(pvs[i].sizeOut); for (j = 0; j < pvs[i].sizeOut; j++) { switch (pinfo[i].elementType) { case AL_INT32_ELEM: case AL_RESOURCE_ELEM: case AL_ENUM_ELEM: PyList_SetItem(item, j, PyInt_FromLong((long) ((int *) pvs[i].value.ptr)[j])); break; case AL_INT64_ELEM: PyList_SetItem(item, j, PyLong_FromLongLong(((long long *) pvs[i].value.ptr)[j])); break; case AL_FIXED_ELEM: PyList_SetItem(item, j, PyFloat_FromDouble(alFixedToDouble(((long long *) pvs[i].value.ptr)[j]))); break; default: PyErr_SetString(ErrorObject, "internal error"); goto error; } } PyMem_DEL(pvs[i].value.ptr); break; case AL_SCALAR_VAL: item = param2python(resource, pvs[i].param, pvs[i].value, &pinfo[i]); break; } if (PyErr_Occurred() || PyList_SetItem(v, i, Py_BuildValue("(iO)", pvs[i].param, item)) < 0 || PyErr_Occurred()) goto error; Py_DECREF(item); } PyMem_DEL(pvs); PyMem_DEL(pinfo); return v; error: Py_XDECREF(v); Py_XDECREF(item); if (pvs) PyMem_DEL(pvs); if (pinfo) PyMem_DEL(pinfo); return NULL;} PyDoc_STRVAR(al_SetParams__doc__,"alSetParams: set the values of audio resource parameters."); static PyObject *al_SetParams(PyObject *self, PyObject *args){ int resource; PyObject *pvslist; ALpv *pvs; ALparamInfo *pinfo; int npvs, i; if (!PyArg_ParseTuple(args, "iO!:SetParams", &resource, &PyList_Type, &pvslist)) return NULL; npvs = python2params(resource, -1, pvslist, &pvs, &pinfo); if (npvs < 0) return NULL; if (alSetParams(resource, pvs, npvs) < 0) goto error; /* cleanup */ for (i = 0; i < npvs; i++) { switch (pinfo[i].valueType) { case AL_SET_VAL: case AL_VECTOR_VAL: PyMem_DEL(pvs[i].value.ptr); break; } } PyMem_DEL(pvs); PyMem_DEL(pinfo); Py_INCREF(Py_None); return Py_None; error: /* XXXX we should clean up everything */ if (pvs) PyMem_DEL(pvs); if (pinfo) PyMem_DEL(pinfo); return NULL;} PyDoc_STRVAR(al_QueryValues__doc__,"alQueryValues: get the set of possible values for a parameter."); static PyObject *al_QueryValues(PyObject *self, PyObject *args){ int resource, param; ALvalue *return_set = NULL; int setsize = 32, qualsize = 0, nvals, i; ALpv *quals = NULL; ALparamInfo pinfo; ALparamInfo *qualinfo = NULL; PyObject *qualobj = NULL; PyObject *res = NULL, *item; if (!PyArg_ParseTuple(args, "ii|O!:QueryValues", &resource, ¶m, &PyList_Type, &qualobj)) return NULL; if (qualobj != NULL) { qualsize = python2params(resource, param, qualobj, &quals, &qualinfo); if (qualsize < 0) return NULL; } setsize = 32; return_set = PyMem_NEW(ALvalue, setsize); if (return_set == NULL) { PyErr_NoMemory(); goto cleanup; } retry: nvals = alQueryValues(resource, param, return_set, setsize, quals, qualsize); if (nvals < 0) goto cleanup; if (nvals > setsize) { setsize = nvals; PyMem_RESIZE(return_set, ALvalue, setsize); if (return_set == NULL) { PyErr_NoMemory(); goto cleanup; } goto retry; } if (alGetParamInfo(resource, param, &pinfo) < 0) goto cleanup; res = PyList_New(nvals); if (res == NULL) goto cleanup; for (i = 0; i < nvals; i++) { item = param2python(resource, param, return_set[i], &pinfo); if (item == NULL || PyList_SetItem(res, i, item) < 0) { Py_DECREF(res); res = NULL; goto cleanup; } } cleanup: if (return_set) PyMem_DEL(return_set); if (quals) { for (i = 0; i < qualsize; i++) { switch (qualinfo[i].valueType) { case AL_SET_VAL: case AL_VECTOR_VAL: PyMem_DEL(quals[i].value.ptr); break; } } PyMem_DEL(quals); PyMem_DEL(qualinfo); } return res;} PyDoc_STRVAR(al_GetParamInfo__doc__,"alGetParamInfo: get information about a parameter on ""a particular audio resource."); static PyObject *al_GetParamInfo(PyObject *self, PyObject *args){ int res, param; ALparamInfo pinfo; PyObject *v, *item; if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, ¶m)) return NULL; if (alGetParamInfo(res, param, &pinfo) < 0) return NULL; v = PyDict_New(); if (!v) return NULL; item = PyInt_FromLong((long) pinfo.resource); PyDict_SetItemString(v, "resource", item); Py_DECREF(item); item = PyInt_FromLong((long) pinfo.param); PyDict_SetItemString(v, "param", item); Py_DECREF(item); item = PyInt_FromLong((long) pinfo.valueType); PyDict_SetItemString(v, "valueType", item); Py_DECREF(item); if (pinfo.valueType != AL_NO_VAL && pinfo.valueType != AL_SCALAR_VAL) { /* multiple values */ item = PyInt_FromLong((long) pinfo.maxElems); PyDict_SetItemString(v, "maxElems", item); Py_DECREF(item); if (pinfo.valueType == AL_MATRIX_VAL) { /* 2 dimensional */ item = PyInt_FromLong((long) pinfo.maxElems2); PyDict_SetItemString(v, "maxElems2", item); Py_DECREF(item); } } item = PyInt_FromLong((long) pinfo.elementType); PyDict_SetItemString(v, "elementType", item); Py_DECREF(item); item = PyString_FromString(pinfo.name); PyDict_SetItemString(v, "name", item); Py_DECREF(item); item = param2python(res, param, pinfo.initial, &pinfo); PyDict_SetItemString(v, "initial", item); Py_DECREF(item); if (pinfo.elementType != AL_ENUM_ELEM && pinfo.elementType != AL_RESOURCE_ELEM && pinfo.elementType != AL_CHAR_ELEM) { /* range param */ item = param2python(res, param, pinfo.min, &pinfo); PyDict_SetItemString(v, "min", item); Py_DECREF(item); item = param2python(res, param, pinfo.max, &pinfo); PyDict_SetItemString(v, "max", item); Py_DECREF(item); item = param2python(res, param, pinfo.minDelta, &pinfo); PyDict_SetItemString(v, "minDelta", item); Py_DECREF(item); item = param2python(res, param, pinfo.maxDelta, &pinfo); PyDict_SetItemString(v, "maxDelta", item); Py_DECREF(item); item = PyInt_FromLong((long) pinfo.specialVals); PyDict_SetItemString(v, "specialVals", item); Py_DECREF(item); } return v;} PyDoc_STRVAR(al_GetResourceByName__doc__,"alGetResourceByName: find an audio resource by name."); static PyObject *al_GetResourceByName(PyObject *self, PyObject *args){ int res, start_res, type; char *name; if (!PyArg_ParseTuple(args, "isi:GetResourceByName", &start_res, &name, &type)) return NULL; if ((res = alGetResourceByName(start_res, name, type)) == 0) return NULL; return PyInt_FromLong((long) res);} PyDoc_STRVAR(al_IsSubtype__doc__,"alIsSubtype: indicate if one resource type is a subtype of another."); static PyObject *al_IsSubtype(PyObject *self, PyObject *args){ int type, subtype; if (!PyArg_ParseTuple(args, "ii:IsSubtype", &type, &subtype)) return NULL; return PyInt_FromLong((long) alIsSubtype(type, subtype));} PyDoc_STRVAR(al_SetErrorHandler__doc__, ""); static PyObject *al_SetErrorHandler(PyObject *self, PyObject *args){ if (!PyArg_ParseTuple(args, ":SetErrorHandler")) return NULL; Py_INCREF(Py_None); return Py_None;} #endif /* AL_NO_ELEM */ #ifdef OLD_INTERFACE static PyObject *al_openport(PyObject *self, PyObject *args){ char *name, *dir; ALport port; alcobject *config = NULL; if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config)) return NULL; if ((port = ALopenport(name, dir, config ? config->config : NULL)) == NULL) return NULL; return newalpobject(port);} static PyObject *al_newconfig(PyObject *self, PyObject *args){ ALconfig config; if (!PyArg_ParseTuple(args, ":NewConfig")) return NULL; if ((config = ALnewconfig ()) == NULL) return NULL; return newalcobject(config);} static PyObject *al_queryparams(PyObject *self, PyObject *args){ long device; long length; long *PVbuffer; long PVdummy[2]; PyObject *v = NULL; int i; if (!PyArg_ParseTuple(args, "l:queryparams", &device)) return NULL; if ((length = ALqueryparams(device, PVdummy, 2L)) == -1) return NULL; if ((PVbuffer = PyMem_NEW(long, length)) == NULL) return PyErr_NoMemory(); if (ALqueryparams(device, PVbuffer, length) >= 0 && (v = PyList_New((int)length)) != NULL) { for (i = 0; i < length; i++) PyList_SetItem(v, i, PyInt_FromLong(PVbuffer[i])); } PyMem_DEL(PVbuffer); return v;} static PyObject *doParams(PyObject *args, int (*func)(long, long *, long), int modified){ long device; PyObject *list, *v; long *PVbuffer; long length; int i; if (!PyArg_ParseTuple(args, "lO!", &device, &PyList_Type, &list)) return NULL; length = PyList_Size(list); PVbuffer = PyMem_NEW(long, length); if (PVbuffer == NULL) return PyErr_NoMemory(); for (i = 0; i < length; i++) { v = PyList_GetItem(list, i); if (!PyInt_Check(v)) { PyMem_DEL(PVbuffer); PyErr_BadArgument(); return NULL; } PVbuffer[i] = PyInt_AsLong(v); } if ((*func)(device, PVbuffer, length) == -1) { PyMem_DEL(PVbuffer); return NULL; } if (modified) { for (i = 0; i < length; i++) PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i])); } PyMem_DEL(PVbuffer); Py_INCREF(Py_None); return Py_None;} static PyObject *al_getparams(PyObject *self, PyObject *args){ return doParams(args, ALgetparams, 1);} static PyObject *al_setparams(PyObject *self, PyObject *args){ return doParams(args, ALsetparams, 0);} static PyObject *al_getname(PyObject *self, PyObject *args){ long device, descriptor; char *name; if (!PyArg_ParseTuple(args, "ll:getname", &device, &descriptor)) return NULL; if ((name = ALgetname(device, descriptor)) == NULL) return NULL; return PyString_FromString(name);} static PyObject *al_getdefault(PyObject *self, PyObject *args){ long device, descriptor, value; if (!PyArg_ParseTuple(args, "ll:getdefault", &device, &descriptor)) return NULL; if ((value = ALgetdefault(device, descriptor)) == -1) return NULL; return PyLong_FromLong(value);} static PyObject *al_getminmax(PyObject *self, PyObject *args){ long device, descriptor, min, max; if (!PyArg_ParseTuple(args, "ll:getminmax", &device, &descriptor)) return NULL; min = -1; max = -1; if (ALgetminmax(device, descriptor, &min, &max) == -1) return NULL; return Py_BuildValue("ll", min, max);} #endif /* OLD_INTERFACE */ /* List of methods defined in the module */ static struct PyMethodDef al_methods[] = {#ifdef AL_NO_ELEM /* IRIX 6 */ {"NewConfig", (PyCFunction)al_NewConfig, METH_VARARGS, al_NewConfig__doc__}, {"OpenPort", (PyCFunction)al_OpenPort, METH_VARARGS, al_OpenPort__doc__}, {"Connect", (PyCFunction)al_Connect, METH_VARARGS, al_Connect__doc__}, {"Disconnect", (PyCFunction)al_Disconnect, METH_VARARGS, al_Disconnect__doc__}, {"GetParams", (PyCFunction)al_GetParams, METH_VARARGS, al_GetParams__doc__}, {"SetParams", (PyCFunction)al_SetParams, METH_VARARGS, al_SetParams__doc__}, {"QueryValues", (PyCFunction)al_QueryValues, METH_VARARGS, al_QueryValues__doc__}, {"GetParamInfo", (PyCFunction)al_GetParamInfo, METH_VARARGS, al_GetParamInfo__doc__}, {"GetResourceByName", (PyCFunction)al_GetResourceByName, METH_VARARGS, al_GetResourceByName__doc__}, {"IsSubtype", (PyCFunction)al_IsSubtype, METH_VARARGS, al_IsSubtype__doc__},#if 0 /* this one not supported */ {"SetErrorHandler", (PyCFunction)al_SetErrorHandler, METH_VARARGS, al_SetErrorHandler__doc__},#endif#endif /* AL_NO_ELEM */#ifdef OLD_INTERFACE {"openport", (PyCFunction)al_openport, METH_VARARGS}, {"newconfig", (PyCFunction)al_newconfig, METH_VARARGS}, {"queryparams", (PyCFunction)al_queryparams, METH_VARARGS}, {"getparams", (PyCFunction)al_getparams, METH_VARARGS}, {"setparams", (PyCFunction)al_setparams, METH_VARARGS}, {"getname", (PyCFunction)al_getname, METH_VARARGS}, {"getdefault", (PyCFunction)al_getdefault, METH_VARARGS}, {"getminmax", (PyCFunction)al_getminmax, METH_VARARGS},#endif /* OLD_INTERFACE */ {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */}; /* Initialization function for the module (*must* be called inital) */ PyDoc_STRVAR(al_module_documentation, ""); voidinital(void){ PyObject *m, *d, *x; /* Create the module and add the functions */ m = Py_InitModule4("al", al_methods, al_module_documentation, (PyObject*)NULL,PYTHON_API_VERSION);Lines 1501–2000 of 3226. Previous lines Load more
item = PyString_FromString(pvs[i].value.ptr); PyMem_DEL(pvs[i].value.ptr); break; case AL_MATRIX_VAL: /* XXXX this is not right */ pvs[i].sizeOut *= pvs[i].size2Out; /* fall through */ case AL_SET_VAL: case AL_VECTOR_VAL: item = PyList_New(pvs[i].sizeOut); for (j = 0; j < pvs[i].sizeOut; j++) { switch (pinfo[i].elementType) { case AL_INT32_ELEM: case AL_RESOURCE_ELEM: case AL_ENUM_ELEM: PyList_SetItem(item, j, PyInt_FromLong((long) ((int *) pvs[i].value.ptr)[j])); break; case AL_INT64_ELEM: PyList_SetItem(item, j, PyLong_FromLongLong(((long long *) pvs[i].value.ptr)[j])); break; case AL_FIXED_ELEM: PyList_SetItem(item, j, PyFloat_FromDouble(alFixedToDouble(((long long *) pvs[i].value.ptr)[j]))); break; default: PyErr_SetString(ErrorObject, "internal error"); goto error; } } PyMem_DEL(pvs[i].value.ptr); break; case AL_SCALAR_VAL: item = param2python(resource, pvs[i].param, pvs[i].value, &pinfo[i]); break; } if (PyErr_Occurred() || PyList_SetItem(v, i, Py_BuildValue("(iO)", pvs[i].param, item)) < 0 || PyErr_Occurred()) goto error; Py_DECREF(item); } PyMem_DEL(pvs); PyMem_DEL(pinfo); return v; error: Py_XDECREF(v); Py_XDECREF(item); if (pvs) PyMem_DEL(pvs); if (pinfo) PyMem_DEL(pinfo); return NULL; } PyDoc_STRVAR(al_SetParams__doc__, "alSetParams: set the values of audio resource parameters."); static PyObject * al_SetParams(PyObject *self, PyObject *args) { int resource; PyObject *pvslist; ALpv *pvs; ALparamInfo *pinfo; int npvs, i; if (!PyArg_ParseTuple(args, "iO!:SetParams", &resource, &PyList_Type, &pvslist)) return NULL; npvs = python2params(resource, -1, pvslist, &pvs, &pinfo); if (npvs < 0) return NULL; if (alSetParams(resource, pvs, npvs) < 0) goto error; /* cleanup */ for (i = 0; i < npvs; i++) { switch (pinfo[i].valueType) { case AL_SET_VAL: case AL_VECTOR_VAL: PyMem_DEL(pvs[i].value.ptr); break; } } PyMem_DEL(pvs); PyMem_DEL(pinfo); Py_INCREF(Py_None); return Py_None; error: /* XXXX we should clean up everything */ if (pvs) PyMem_DEL(pvs); if (pinfo) PyMem_DEL(pinfo); return NULL; } PyDoc_STRVAR(al_QueryValues__doc__, "alQueryValues: get the set of possible values for a parameter."); static PyObject * al_QueryValues(PyObject *self, PyObject *args) { int resource, param; ALvalue *return_set = NULL; int setsize = 32, qualsize = 0, nvals, i; ALpv *quals = NULL; ALparamInfo pinfo; ALparamInfo *qualinfo = NULL; PyObject *qualobj = NULL; PyObject *res = NULL, *item; if (!PyArg_ParseTuple(args, "ii|O!:QueryValues", &resource, ¶m, &PyList_Type, &qualobj)) return NULL; if (qualobj != NULL) { qualsize = python2params(resource, param, qualobj, &quals, &qualinfo); if (qualsize < 0) return NULL; } setsize = 32; return_set = PyMem_NEW(ALvalue, setsize); if (return_set == NULL) { PyErr_NoMemory(); goto cleanup; } retry: nvals = alQueryValues(resource, param, return_set, setsize, quals, qualsize); if (nvals < 0) goto cleanup; if (nvals > setsize) { setsize = nvals; PyMem_RESIZE(return_set, ALvalue, setsize); if (return_set == NULL) { PyErr_NoMemory(); goto cleanup; } goto retry; } if (alGetParamInfo(resource, param, &pinfo) < 0) goto cleanup; res = PyList_New(nvals); if (res == NULL) goto cleanup; for (i = 0; i < nvals; i++) { item = param2python(resource, param, return_set[i], &pinfo); if (item == NULL || PyList_SetItem(res, i, item) < 0) { Py_DECREF(res); res = NULL; goto cleanup; } } cleanup: if (return_set) PyMem_DEL(return_set); if (quals) { for (i = 0; i < qualsize; i++) { switch (qualinfo[i].valueType) { case AL_SET_VAL: case AL_VECTOR_VAL: PyMem_DEL(quals[i].value.ptr); break; } } PyMem_DEL(quals); PyMem_DEL(qualinfo); } return res; } PyDoc_STRVAR(al_GetParamInfo__doc__, "alGetParamInfo: get information about a parameter on " "a particular audio resource."); static PyObject * al_GetParamInfo(PyObject *self, PyObject *args) { int res, param; ALparamInfo pinfo; PyObject *v, *item; if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, ¶m)) return NULL; if (alGetParamInfo(res, param, &pinfo) < 0) return NULL; v = PyDict_New(); if (!v) return NULL; item = PyInt_FromLong((long) pinfo.resource); PyDict_SetItemString(v, "resource", item); Py_DECREF(item); item = PyInt_FromLong((long) pinfo.param); PyDict_SetItemString(v, "param", item); Py_DECREF(item); item = PyInt_FromLong((long) pinfo.valueType); PyDict_SetItemString(v, "valueType", item); Py_DECREF(item); if (pinfo.valueType != AL_NO_VAL && pinfo.valueType != AL_SCALAR_VAL) { /* multiple values */ item = PyInt_FromLong((long) pinfo.maxElems); PyDict_SetItemString(v, "maxElems", item); Py_DECREF(item); if (pinfo.valueType == AL_MATRIX_VAL) { /* 2 dimensional */ item = PyInt_FromLong((long) pinfo.maxElems2); PyDict_SetItemString(v, "maxElems2", item); Py_DECREF(item); } } item = PyInt_FromLong((long) pinfo.elementType); PyDict_SetItemString(v, "elementType", item); Py_DECREF(item); item = PyString_FromString(pinfo.name); PyDict_SetItemString(v, "name", item); Py_DECREF(item); item = param2python(res, param, pinfo.initial, &pinfo); PyDict_SetItemString(v, "initial", item); Py_DECREF(item); if (pinfo.elementType != AL_ENUM_ELEM && pinfo.elementType != AL_RESOURCE_ELEM && pinfo.elementType != AL_CHAR_ELEM) { /* range param */ item = param2python(res, param, pinfo.min, &pinfo); PyDict_SetItemString(v, "min", item); Py_DECREF(item); item = param2python(res, param, pinfo.max, &pinfo); PyDict_SetItemString(v, "max", item); Py_DECREF(item); item = param2python(res, param, pinfo.minDelta, &pinfo); PyDict_SetItemString(v, "minDelta", item); Py_DECREF(item); item = param2python(res, param, pinfo.maxDelta, &pinfo); PyDict_SetItemString(v, "maxDelta", item); Py_DECREF(item); item = PyInt_FromLong((long) pinfo.specialVals); PyDict_SetItemString(v, "specialVals", item); Py_DECREF(item); } return v; } PyDoc_STRVAR(al_GetResourceByName__doc__, "alGetResourceByName: find an audio resource by name."); static PyObject * al_GetResourceByName(PyObject *self, PyObject *args) { int res, start_res, type; char *name; if (!PyArg_ParseTuple(args, "isi:GetResourceByName", &start_res, &name, &type)) return NULL; if ((res = alGetResourceByName(start_res, name, type)) == 0) return NULL; return PyInt_FromLong((long) res); } PyDoc_STRVAR(al_IsSubtype__doc__, "alIsSubtype: indicate if one resource type is a subtype of another."); static PyObject * al_IsSubtype(PyObject *self, PyObject *args) { int type, subtype; if (!PyArg_ParseTuple(args, "ii:IsSubtype", &type, &subtype)) return NULL; return PyInt_FromLong((long) alIsSubtype(type, subtype)); } PyDoc_STRVAR(al_SetErrorHandler__doc__, ""); static PyObject * al_SetErrorHandler(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":SetErrorHandler")) return NULL; Py_INCREF(Py_None); return Py_None; } #endif /* AL_NO_ELEM */ #ifdef OLD_INTERFACE static PyObject * al_openport(PyObject *self, PyObject *args) { char *name, *dir; ALport port; alcobject *config = NULL; if (!PyArg_ParseTuple(args, "ss|O!:OpenPort", &name, &dir, &Alctype, &config)) return NULL; if ((port = ALopenport(name, dir, config ? config->config : NULL)) == NULL) return NULL; return newalpobject(port); } static PyObject * al_newconfig(PyObject *self, PyObject *args) { ALconfig config; if (!PyArg_ParseTuple(args, ":NewConfig")) return NULL; if ((config = ALnewconfig ()) == NULL) return NULL; return newalcobject(config); } static PyObject * al_queryparams(PyObject *self, PyObject *args) { long device; long length; long *PVbuffer; long PVdummy[2]; PyObject *v = NULL; int i; if (!PyArg_ParseTuple(args, "l:queryparams", &device)) return NULL; if ((length = ALqueryparams(device, PVdummy, 2L)) == -1) return NULL; if ((PVbuffer = PyMem_NEW(long, length)) == NULL) return PyErr_NoMemory(); if (ALqueryparams(device, PVbuffer, length) >= 0 && (v = PyList_New((int)length)) != NULL) { for (i = 0; i < length; i++) PyList_SetItem(v, i, PyInt_FromLong(PVbuffer[i])); } PyMem_DEL(PVbuffer); return v; } static PyObject * doParams(PyObject *args, int (*func)(long, long *, long), int modified) { long device; PyObject *list, *v; long *PVbuffer; long length; int i; if (!PyArg_ParseTuple(args, "lO!", &device, &PyList_Type, &list)) return NULL; length = PyList_Size(list); PVbuffer = PyMem_NEW(long, length); if (PVbuffer == NULL) return PyErr_NoMemory(); for (i = 0; i < length; i++) { v = PyList_GetItem(list, i); if (!PyInt_Check(v)) { PyMem_DEL(PVbuffer); PyErr_BadArgument(); return NULL; } PVbuffer[i] = PyInt_AsLong(v); } if ((*func)(device, PVbuffer, length) == -1) { PyMem_DEL(PVbuffer); return NULL; } if (modified) { for (i = 0; i < length; i++) PyList_SetItem(list, i, PyInt_FromLong(PVbuffer[i])); } PyMem_DEL(PVbuffer); Py_INCREF(Py_None); return Py_None; } static PyObject * al_getparams(PyObject *self, PyObject *args) { return doParams(args, ALgetparams, 1); } static PyObject * al_setparams(PyObject *self, PyObject *args) { return doParams(args, ALsetparams, 0); } static PyObject * al_getname(PyObject *self, PyObject *args) { long device, descriptor; char *name; if (!PyArg_ParseTuple(args, "ll:getname", &device, &descriptor)) return NULL; if ((name = ALgetname(device, descriptor)) == NULL) return NULL; return PyString_FromString(name); } static PyObject * al_getdefault(PyObject *self, PyObject *args) { long device, descriptor, value; if (!PyArg_ParseTuple(args, "ll:getdefault", &device, &descriptor)) return NULL; if ((value = ALgetdefault(device, descriptor)) == -1) return NULL; return PyLong_FromLong(value); } static PyObject * al_getminmax(PyObject *self, PyObject *args) { long device, descriptor, min, max; if (!PyArg_ParseTuple(args, "ll:getminmax", &device, &descriptor)) return NULL; min = -1; max = -1; if (ALgetminmax(device, descriptor, &min, &max) == -1) return NULL; return Py_BuildValue("ll", min, max); } #endif /* OLD_INTERFACE */ /* List of methods defined in the module */ static struct PyMethodDef al_methods[] = { #ifdef AL_NO_ELEM /* IRIX 6 */ {"NewConfig", (PyCFunction)al_NewConfig, METH_VARARGS, al_NewConfig__doc__}, {"OpenPort", (PyCFunction)al_OpenPort, METH_VARARGS, al_OpenPort__doc__}, {"Connect", (PyCFunction)al_Connect, METH_VARARGS, al_Connect__doc__}, {"Disconnect", (PyCFunction)al_Disconnect, METH_VARARGS, al_Disconnect__doc__}, {"GetParams", (PyCFunction)al_GetParams, METH_VARARGS, al_GetParams__doc__}, {"SetParams", (PyCFunction)al_SetParams, METH_VARARGS, al_SetParams__doc__}, {"QueryValues", (PyCFunction)al_QueryValues, METH_VARARGS, al_QueryValues__doc__}, {"GetParamInfo", (PyCFunction)al_GetParamInfo, METH_VARARGS, al_GetParamInfo__doc__}, {"GetResourceByName", (PyCFunction)al_GetResourceByName, METH_VARARGS, al_GetResourceByName__doc__}, {"IsSubtype", (PyCFunction)al_IsSubtype, METH_VARARGS, al_IsSubtype__doc__}, #if 0 /* this one not supported */ {"SetErrorHandler", (PyCFunction)al_SetErrorHandler, METH_VARARGS, al_SetErrorHandler__doc__}, #endif #endif /* AL_NO_ELEM */ #ifdef OLD_INTERFACE {"openport", (PyCFunction)al_openport, METH_VARARGS}, {"newconfig", (PyCFunction)al_newconfig, METH_VARARGS}, {"queryparams", (PyCFunction)al_queryparams, METH_VARARGS}, {"getparams", (PyCFunction)al_getparams, METH_VARARGS}, {"setparams", (PyCFunction)al_setparams, METH_VARARGS}, {"getname", (PyCFunction)al_getname, METH_VARARGS}, {"getdefault", (PyCFunction)al_getdefault, METH_VARARGS}, {"getminmax", (PyCFunction)al_getminmax, METH_VARARGS}, #endif /* OLD_INTERFACE */ {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ }; /* Initialization function for the module (*must* be called inital) */ PyDoc_STRVAR(al_module_documentation, ""); void inital(void) { PyObject *m, *d, *x; /* Create the module and add the functions */ m = Py_InitModule4("al", al_methods, al_module_documentation, (PyObject*)NULL,PYTHON_API_VERSION);