X-Git-Url: https://scm.cri.ensmp.fr/git/linpy.git/blobdiff_plain/66e41ccd173874b3309e4c24be64c7b6b2ac6298..1d494bb187b70135df721c13306d7f26fdf33f50:/pypol/_isl.c diff --git a/pypol/_isl.c b/pypol/_isl.c deleted file mode 100644 index 1b086dc..0000000 --- a/pypol/_isl.c +++ /dev/null @@ -1,89 +0,0 @@ -#include - -#include -#include - -struct pointer_list { - int cursor; - PyObject *pointers; -}; -typedef struct pointer_list pointer_list; - -static int pointer_list_append_constraint(isl_constraint *c, void *user) { - pointer_list *list; - PyObject *value; - - list = (pointer_list *) user; - value = PyLong_FromVoidPtr(c); - if (value == NULL) { - return -1; - } - PyList_SET_ITEM(list->pointers, list->cursor++, value); - return 0; -} - -static PyObject * basic_set_constraints(PyObject *self, PyObject* args) { - long ptr; - isl_basic_set *bset; - int n; - PyObject *pointers; - pointer_list *list; - - if (!PyArg_ParseTuple(args, "l", &ptr)) - return NULL; - bset = (isl_basic_set*) ptr; - n = isl_basic_set_n_constraint(bset); - if (n == -1) { - PyErr_SetString(PyExc_RuntimeError, - "an error occurred in isl_basic_set_n_constraint"); - return NULL; - } - pointers = PyList_New(n); - if (pointers == NULL) { - return NULL; - } - list = malloc(sizeof(pointer_list)); - if (list == NULL) { - Py_DECREF(pointers); - return PyErr_NoMemory(); - } - list->cursor = 0; - list->pointers = pointers; - n = isl_basic_set_foreach_constraint(bset, pointer_list_append_constraint, - list); - free(list); - if (n == -1) { - PyErr_SetString(PyExc_RuntimeError, - "an error occurred in isl_basic_set_foreach_constraint"); - Py_DECREF(pointers); - return NULL; - } - return pointers; -} - -static PyMethodDef _isl_methods[] = { - {"basic_set_constraints", basic_set_constraints, METH_VARARGS, NULL}, - {NULL, NULL, 0, NULL} -}; - -static struct PyModuleDef _islmodule = { - PyModuleDef_HEAD_INIT, - "_isl", - NULL, - 0, - _isl_methods -}; - -PyMODINIT_FUNC PyInit__isl(void) { - PyObject *m; - m = PyModule_Create(&_islmodule); - if (m == NULL) { - return NULL; - } - - if (PyModule_AddObject(m, "dim_set", PyLong_FromLong(isl_dim_set)) == -1) { - return NULL; - } - - return m; -}