Mercurial > hg > vampy
view PyParameterDescriptor.cpp @ 35:2ba482378038 vampy2
* Fix compile error with VC++. I am totally at a loss to explain
why this should have compiled with any other compiler!
* Update VC project file.
This code does now build with VC++ without HAVE_NUMPY -- I haven't
installed Numpy yet
author | cannam |
---|---|
date | Thu, 24 Sep 2009 08:52:04 +0000 |
parents | 4f1894c7591b |
children |
line wrap: on
line source
#include <Python.h> #include "PyParameterDescriptor.h" #include "vamp-sdk/Plugin.h" #include <string> #include "PyTypeInterface.h" using namespace std; using namespace Vamp; using Vamp::Plugin; /* ParameterDescriptor Object's Methods */ //Feature objects have no callable methods /* PyParameterDescriptor methods implementing protocols */ // these functions are called by the interpreter automatically /* New ParameterDescriptor object */ static PyObject * ParameterDescriptor_new(PyTypeObject *type, PyObject *args, PyObject *kw) { if (!PyArg_ParseTuple(args, ":ParameterDescriptor")) { PyErr_SetString(PyExc_TypeError, "Error: ParameterDescriptor initialised with arguments."); return NULL; } ParameterDescriptorObject *self = (ParameterDescriptorObject*)type->tp_alloc(type, 0); if (self == NULL) return NULL; self->dict = PyDict_New(); if (self->dict == NULL) return NULL; return (PyObject *) self; } /* DESTRUCTOR: delete type object */ static void ParameterDescriptorObject_dealloc(ParameterDescriptorObject *self) { Py_XDECREF(self->dict); PyObject_Del(self); } /* Set attributes */ static int ParameterDescriptor_setattr(ParameterDescriptorObject *self, char *name, PyObject *v) { if (v == NULL) { int rv = PyDict_DelItemString(self->dict, name); if (rv < 0) PyErr_SetString(PyExc_AttributeError,"non-existing ParameterDescriptor attribute"); return rv; } else return PyDict_SetItemString(self->dict, name, v); } /* Get attributes */ static PyObject * ParameterDescriptor_getattr(ParameterDescriptorObject *self, char *name) { if (self->dict != NULL) { PyObject *v = PyDict_GetItemString(self->dict, name); if (v != NULL) { Py_INCREF(v); return v; } } return NULL; } /* String representation */ static PyObject * ParameterDescriptor_repr(PyObject *self) { // if (PyFeature_CheckExact(self)) {} // PyObject* intdict = self return Py_BuildValue("s", "not yet implemented"); // ((RealTimeObject*)self)->rt->toString().c_str()); } #define ParameterDescriptor_alloc PyType_GenericAlloc #define ParameterDescriptor_free PyObject_Del PyTypeObject ParameterDescriptor_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "vampy.ParameterDescriptor",/*tp_name*/ sizeof(ParameterDescriptorObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)ParameterDescriptorObject_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)ParameterDescriptor_getattr, /*tp_getattr*/ (setattrfunc)ParameterDescriptor_setattr, /*tp_setattr*/ 0, /*tp_compare*/ ParameterDescriptor_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ 0, /*tp_methods*/ //TypeObject Methods 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ ParameterDescriptor_alloc,/*tp_alloc*/ ParameterDescriptor_new,/*tp_new*/ ParameterDescriptor_free,/*tp_free*/ 0, /*tp_is_gc*/ }; /* PyParameterDescriptor C++ API */