[965ea78] | 1 | #include "aubio-types.h" |
---|
| 2 | |
---|
| 3 | #define AUBIO_DECLARE(NAME, PARAMS...) \ |
---|
| 4 | typedef struct { \ |
---|
| 5 | PyObject_HEAD \ |
---|
| 6 | aubio_ ## NAME ## _t * o; \ |
---|
| 7 | PARAMS; \ |
---|
| 8 | } Py_## NAME; |
---|
| 9 | |
---|
| 10 | #define AUBIO_INIT(NAME, PARAMS... ) \ |
---|
| 11 | static int \ |
---|
| 12 | Py_ ## NAME ## _init (Py_ ## NAME * self, PyObject * args, PyObject * kwds) \ |
---|
| 13 | { \ |
---|
| 14 | self->o = new_aubio_## NAME ( PARAMS ); \ |
---|
| 15 | if (self->o == NULL) { \ |
---|
[ab59067] | 16 | PyErr_SetString (PyExc_StandardError, "error creating object"); \ |
---|
[965ea78] | 17 | return -1; \ |
---|
| 18 | } \ |
---|
| 19 | \ |
---|
| 20 | return 0; \ |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | #define AUBIO_DEL(NAME) \ |
---|
| 24 | static void \ |
---|
| 25 | Py_ ## NAME ## _del ( Py_ ## NAME * self) \ |
---|
| 26 | { \ |
---|
| 27 | del_aubio_ ## NAME (self->o); \ |
---|
| 28 | self->ob_type->tp_free ((PyObject *) self); \ |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | #define AUBIO_MEMBERS_START(NAME) \ |
---|
| 32 | static PyMemberDef Py_ ## NAME ## _members[] = { |
---|
| 33 | |
---|
| 34 | #define AUBIO_MEMBERS_STOP(NAME) \ |
---|
| 35 | {NULL} \ |
---|
| 36 | }; |
---|
| 37 | |
---|
| 38 | #define AUBIO_METHODS(NAME) \ |
---|
| 39 | static PyMethodDef Py_ ## NAME ## _methods[] = { \ |
---|
| 40 | {NULL} \ |
---|
| 41 | }; |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | #define AUBIO_TYPEOBJECT(NAME, PYNAME) \ |
---|
| 45 | PyTypeObject Py_ ## NAME ## Type = { \ |
---|
| 46 | PyObject_HEAD_INIT (NULL) \ |
---|
| 47 | 0, \ |
---|
| 48 | PYNAME, \ |
---|
| 49 | sizeof (Py_ ## NAME), \ |
---|
| 50 | 0, \ |
---|
| 51 | (destructor) Py_ ## NAME ## _del, \ |
---|
| 52 | 0, \ |
---|
| 53 | 0, \ |
---|
| 54 | 0, \ |
---|
| 55 | 0, \ |
---|
| 56 | 0, \ |
---|
| 57 | 0, \ |
---|
| 58 | 0, \ |
---|
| 59 | 0, \ |
---|
| 60 | 0, \ |
---|
| 61 | (ternaryfunc)Py_ ## NAME ## _do, \ |
---|
| 62 | 0, \ |
---|
| 63 | 0, \ |
---|
| 64 | 0, \ |
---|
| 65 | 0, \ |
---|
| 66 | Py_TPFLAGS_DEFAULT, \ |
---|
| 67 | Py_ ## NAME ## _doc, \ |
---|
| 68 | 0, \ |
---|
| 69 | 0, \ |
---|
| 70 | 0, \ |
---|
| 71 | 0, \ |
---|
| 72 | 0, \ |
---|
| 73 | 0, \ |
---|
| 74 | Py_ ## NAME ## _methods, \ |
---|
| 75 | Py_ ## NAME ## _members, \ |
---|
| 76 | 0, \ |
---|
| 77 | 0, \ |
---|
| 78 | 0, \ |
---|
| 79 | 0, \ |
---|
| 80 | 0, \ |
---|
| 81 | 0, \ |
---|
| 82 | (initproc) Py_ ## NAME ## _init, \ |
---|
| 83 | 0, \ |
---|
| 84 | Py_ ## NAME ## _new, \ |
---|
| 85 | }; |
---|
| 86 | |
---|
| 87 | // some more helpers |
---|
[96fe713] | 88 | #define AUBIO_NEW_VEC(name, type, lengthval) \ |
---|
[965ea78] | 89 | name = (type *) PyObject_New (type, & type ## Type); \ |
---|
| 90 | name->length = lengthval; |
---|