X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/1d494bb187b70135df721c13306d7f26fdf33f50..2b3c6f898db2c17e3be955707629645bbeff91c0:/pypol/_islhelper.c diff --git a/pypol/_islhelper.c b/pypol/_islhelper.c index f8c03e3..37e7c31 100644 --- a/pypol/_islhelper.c +++ b/pypol/_islhelper.c @@ -36,6 +36,7 @@ static PyObject * isl_basic_set_constraints(PyObject *self, PyObject* args) { return NULL; } bset = (isl_basic_set *) ptr; + bset = isl_basic_set_finalize(bset); // this instruction should not be required n = isl_basic_set_n_constraint(bset); if (n == -1) { PyErr_SetString(PyExc_RuntimeError, @@ -119,9 +120,46 @@ static PyObject * isl_set_basic_sets(PyObject *self, PyObject *args) { } +static int pointer_list_append_point(isl_point *point, void *user) { + PyObject *pointers, *value; + + pointers = (PyObject *) user; + value = PyLong_FromVoidPtr(point); + if (value == NULL) { + return -1; + } + return PyList_Append(pointers, value); +} + +static PyObject * isl_set_points(PyObject *self, PyObject *args) { + long ptr; + isl_set *set; + int n; + PyObject *pointers; + + if (!PyArg_ParseTuple(args, "l", &ptr)) { + return NULL; + } + set = (isl_set *) ptr; + pointers = PyList_New(0); + if (pointers == NULL) { + return NULL; + } + n = isl_set_foreach_point(set, pointer_list_append_point, pointers); + if (n == -1) { + PyErr_SetString(PyExc_RuntimeError, + "an error occurred in isl_set_foreach_point"); + Py_DECREF(pointers); + return NULL; + } + return pointers; +} + + static PyMethodDef _islhelper_methods[] = { {"isl_basic_set_constraints", isl_basic_set_constraints, METH_VARARGS, NULL}, {"isl_set_basic_sets", isl_set_basic_sets, METH_VARARGS, NULL}, + {"isl_set_points", isl_set_points, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} };