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