2 This file is part of Linpy.
4 Linpy is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Linpy is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Linpy. If not, see <http://www.gnu.org/licenses/>.
20 #include <isl/constraint.h>
22 #include <isl/vertices.h>
25 static inline int _append_pointer_to_list(void *pointer
, void *user
) {
26 PyObject
*list
, *item
;
27 list
= (PyObject
*) user
;
28 item
= PyLong_FromVoidPtr(pointer
);
32 return PyList_Append(list
, item
);
35 static int _append_constraint_to_list(isl_constraint
*constraint
, void *user
) {
36 return _append_pointer_to_list((void *) constraint
, user
);
39 static PyObject
* isl_basic_set_constraints(PyObject
*self
, PyObject
*args
) {
43 if (!PyArg_ParseTuple(args
, "l", &pointer
)) {
46 bset
= (isl_basic_set
*) pointer
;
51 if (isl_basic_set_foreach_constraint(bset
, _append_constraint_to_list
, list
) == -1) {
52 PyErr_SetString(PyExc_RuntimeError
,
53 "an error occurred in isl_basic_set_foreach_constraint");
60 static int _append_basic_set_to_list(isl_basic_set
*bset
, void *user
) {
61 return _append_pointer_to_list((void *) bset
, user
);
64 static PyObject
* isl_set_basic_sets(PyObject
*self
, PyObject
*args
) {
68 if (!PyArg_ParseTuple(args
, "l", &pointer
)) {
71 set
= (isl_set
*) pointer
;
76 if (isl_set_foreach_basic_set(set
, _append_basic_set_to_list
, list
) == -1) {
77 PyErr_SetString(PyExc_RuntimeError
,
78 "an error occurred in isl_set_foreach_basic_set");
85 static int _append_point_to_list(isl_point
*point
, void* user
) {
86 return _append_pointer_to_list((void *) point
, user
);
89 static PyObject
* isl_set_points(PyObject
*self
, PyObject
*args
) {
93 if (!PyArg_ParseTuple(args
, "l", &pointer
)) {
96 set
= (isl_set
*) pointer
;
101 if (isl_set_foreach_point(set
, _append_point_to_list
, list
) == -1) {
102 PyErr_SetString(PyExc_RuntimeError
,
103 "an error occurred in isl_set_foreach_point");
110 static int _append_vertex_to_list(isl_vertex
*vertex
, void* user
) {
111 return _append_pointer_to_list((void *) vertex
, user
);
114 static PyObject
* isl_vertices_vertices(PyObject
*self
, PyObject
*args
) {
116 isl_vertices
*vertices
;
118 if (!PyArg_ParseTuple(args
, "l", &pointer
)) {
121 vertices
= (isl_vertices
*) pointer
;
122 list
= PyList_New(0);
126 if (isl_vertices_foreach_vertex(vertices
, _append_vertex_to_list
, list
) == -1) {
127 PyErr_SetString(PyExc_RuntimeError
,
128 "an error occurred in isl_vertices_foreach_vertex");
136 static PyMethodDef _islhelper_methods
[] = {
137 {"isl_basic_set_constraints", isl_basic_set_constraints
, METH_VARARGS
, NULL
},
138 {"isl_set_basic_sets", isl_set_basic_sets
, METH_VARARGS
, NULL
},
139 {"isl_set_points", isl_set_points
, METH_VARARGS
, NULL
},
140 {"isl_vertices_vertices", isl_vertices_vertices
, METH_VARARGS
, NULL
},
141 {NULL
, NULL
, 0, NULL
}
144 static struct PyModuleDef _islhelpermodule
= {
145 PyModuleDef_HEAD_INIT
,
152 PyMODINIT_FUNC
PyInit__islhelper(void) {
154 m
= PyModule_Create(&_islhelpermodule
);
158 if (PyModule_AddObject(m
, "dim_set", PyLong_FromLong(isl_dim_set
)) == -1) {
164 // Copyright 2014 MINES ParisTech