comparison PyPluginObject.cpp @ 37:fd249e29a721

Add remaining accessors to plugin; move outputs to getOutputs (distinguishing between static parameters and dynamic output descriptors... is this wise?)
author Chris Cannam
date Wed, 26 Nov 2014 14:20:54 +0000
parents 20a9fcbc2f5f
children 13dcfe8c7ed7
comparison
equal deleted inserted replaced
36:20a9fcbc2f5f 37:fd249e29a721
150 150
151 PyList_SET_ITEM(params, i, paramdict); 151 PyList_SET_ITEM(params, i, paramdict);
152 } 152 }
153 153
154 pd->parameters = params; 154 pd->parameters = params;
155 155
156 Plugin::OutputList ol = plugin->getOutputDescriptors(); 156 return (PyObject *)pd;
157 }
158
159 static void
160 PyPluginObject_dealloc(PyPluginObject *self)
161 {
162 delete self->plugin;
163 PyObject_Del(self);
164 }
165
166 static PyObject *
167 getOutputs(PyObject *self, PyObject *args)
168 {
169 PyPluginObject *pd = getPluginObject(self);
170 if (!pd) return 0;
171
172 Plugin::OutputList ol = pd->plugin->getOutputDescriptors();
157 PyObject *outputs = PyList_New(ol.size()); 173 PyObject *outputs = PyList_New(ol.size());
158 174
159 for (int i = 0; i < (int)ol.size(); ++i) { 175 for (int i = 0; i < (int)ol.size(); ++i) {
160 PyObject *outdict = PyDict_New(); 176 PyObject *outdict = PyDict_New();
161 PyDict_SetItemString 177 PyDict_SetItemString
196 (outdict, "hasDuration", ol[i].hasDuration ? Py_True : Py_False); 212 (outdict, "hasDuration", ol[i].hasDuration ? Py_True : Py_False);
197 213
198 PyList_SET_ITEM(outputs, i, outdict); 214 PyList_SET_ITEM(outputs, i, outdict);
199 } 215 }
200 216
201 pd->outputs = outputs; 217 return outputs;
202
203 return (PyObject *)pd;
204 }
205
206 static void
207 PyPluginObject_dealloc(PyPluginObject *self)
208 {
209 delete self->plugin;
210 PyObject_Del(self);
211 } 218 }
212 219
213 static PyObject * 220 static PyObject *
214 vampyhost_initialise(PyObject *self, PyObject *args) 221 vampyhost_initialise(PyObject *self, PyObject *args)
215 { 222 {
428 435
429 return convertFeatureSet(fs); 436 return convertFeatureSet(fs);
430 } 437 }
431 438
432 static PyObject * 439 static PyObject *
440 vampyhost_getPreferredBlockSize(PyObject *self, PyObject *)
441 {
442 PyPluginObject *pd = getPluginObject(self);
443 if (!pd) return 0;
444 return PyInt_FromLong(pd->plugin->getPreferredBlockSize());
445 }
446
447 static PyObject *
448 vampyhost_getPreferredStepSize(PyObject *self, PyObject *)
449 {
450 PyPluginObject *pd = getPluginObject(self);
451 if (!pd) return 0;
452 return PyInt_FromLong(pd->plugin->getPreferredStepSize());
453 }
454
455 static PyObject *
456 vampyhost_getMinChannelCount(PyObject *self, PyObject *)
457 {
458 PyPluginObject *pd = getPluginObject(self);
459 if (!pd) return 0;
460 return PyInt_FromLong(pd->plugin->getMinChannelCount());
461 }
462
463 static PyObject *
464 vampyhost_getMaxChannelCount(PyObject *self, PyObject *)
465 {
466 PyPluginObject *pd = getPluginObject(self);
467 if (!pd) return 0;
468 return PyInt_FromLong(pd->plugin->getMaxChannelCount());
469 }
470
471 static PyObject *
433 vampyhost_unload(PyObject *self, PyObject *) 472 vampyhost_unload(PyObject *self, PyObject *)
434 { 473 {
435 PyPluginObject *pd = getPluginObject(self); 474 PyPluginObject *pd = getPluginObject(self);
436 if (!pd) return 0; 475 if (!pd) return 0;
437 476
450 {(char *)"inputDomain", T_INT, offsetof(PyPluginObject, inputDomain), READONLY, 489 {(char *)"inputDomain", T_INT, offsetof(PyPluginObject, inputDomain), READONLY,
451 xx_foo_doc}, 490 xx_foo_doc},
452 491
453 {(char *)"parameters", T_OBJECT, offsetof(PyPluginObject, parameters), READONLY, 492 {(char *)"parameters", T_OBJECT, offsetof(PyPluginObject, parameters), READONLY,
454 xx_foo_doc}, 493 xx_foo_doc},
455
456 {(char *)"outputs", T_OBJECT, offsetof(PyPluginObject, outputs), READONLY,
457 xx_foo_doc},
458 494
459 {0, 0} 495 {0, 0}
460 }; 496 };
461 497
462 static PyMethodDef PyPluginObject_methods[] = 498 static PyMethodDef PyPluginObject_methods[] =
463 { 499 {
464 {"getParameter", vampyhost_getParameter, METH_VARARGS, 500 {"getOutputs", getOutputs, METH_NOARGS,
501 xx_foo_doc},
502
503 {"getParameterValue", vampyhost_getParameter, METH_VARARGS,
465 xx_foo_doc}, //!!! fix all these! 504 xx_foo_doc}, //!!! fix all these!
466 505
467 {"setParameter", vampyhost_setParameter, METH_VARARGS, 506 {"setParameterValue", vampyhost_setParameter, METH_VARARGS,
507 xx_foo_doc},
508
509 {"getPreferredBlockSize", vampyhost_getPreferredBlockSize, METH_VARARGS,
510 xx_foo_doc}, //!!! fix all these!
511
512 {"getPreferredStepSize", vampyhost_getPreferredStepSize, METH_VARARGS,
513 xx_foo_doc},
514
515 {"getMinChannelCount", vampyhost_getMinChannelCount, METH_VARARGS,
516 xx_foo_doc}, //!!! fix all these!
517
518 {"getMaxChannelCount", vampyhost_getMaxChannelCount, METH_VARARGS,
468 xx_foo_doc}, 519 xx_foo_doc},
469 520
470 {"initialise", vampyhost_initialise, METH_VARARGS, 521 {"initialise", vampyhost_initialise, METH_VARARGS,
471 xx_foo_doc}, 522 xx_foo_doc},
472 523