3 #include <isl/constraint.h>
5 #include <isl/vertices.h>
8 static inline int _append_pointer_to_list(void *pointer
, void *user
) {
10 list
= (PyObject
*) user
;
11 item
= PyLong_FromVoidPtr(pointer
);
15 return PyList_Append(list
, item
);
18 static int _append_constraint_to_list(isl_constraint
*constraint
, void *user
) {
19 return _append_pointer_to_list((void *) constraint
, user
);
22 static PyObject
* isl_basic_set_constraints(PyObject
*self
, PyObject
*args
) {
26 if (!PyArg_ParseTuple(args
, "l", &pointer
)) {
29 bset
= (isl_basic_set
*) pointer
;
34 if (isl_basic_set_foreach_constraint(bset
, _append_constraint_to_list
, list
) == -1) {
35 PyErr_SetString(PyExc_RuntimeError
,
36 "an error occurred in isl_basic_set_foreach_constraint");
43 static int _append_basic_set_to_list(isl_basic_set
*bset
, void *user
) {
44 return _append_pointer_to_list((void *) bset
, user
);
47 static PyObject
* isl_set_basic_sets(PyObject
*self
, PyObject
*args
) {
51 if (!PyArg_ParseTuple(args
, "l", &pointer
)) {
54 set
= (isl_set
*) pointer
;
59 if (isl_set_foreach_basic_set(set
, _append_basic_set_to_list
, list
) == -1) {
60 PyErr_SetString(PyExc_RuntimeError
,
61 "an error occurred in isl_set_foreach_basic_set");
68 static int _append_point_to_list(isl_point
*point
, void* user
) {
69 return _append_pointer_to_list((void *) point
, user
);
72 static PyObject
* isl_set_points(PyObject
*self
, PyObject
*args
) {
76 if (!PyArg_ParseTuple(args
, "l", &pointer
)) {
79 set
= (isl_set
*) pointer
;
84 if (isl_set_foreach_point(set
, _append_point_to_list
, list
) == -1) {
85 PyErr_SetString(PyExc_RuntimeError
,
86 "an error occurred in isl_set_foreach_point");
93 static int _append_vertex_to_list(isl_vertex
*vertex
, void* user
) {
94 return _append_pointer_to_list((void *) vertex
, user
);
97 static PyObject
* isl_vertices_vertices(PyObject
*self
, PyObject
*args
) {
99 isl_vertices
*vertices
;
101 if (!PyArg_ParseTuple(args
, "l", &pointer
)) {
104 vertices
= (isl_vertices
*) pointer
;
105 list
= PyList_New(0);
109 if (isl_vertices_foreach_vertex(vertices
, _append_vertex_to_list
, list
) == -1) {
110 PyErr_SetString(PyExc_RuntimeError
,
111 "an error occurred in isl_vertices_foreach_vertex");
119 static PyMethodDef _islhelper_methods
[] = {
120 {"isl_basic_set_constraints", isl_basic_set_constraints
, METH_VARARGS
, NULL
},
121 {"isl_set_basic_sets", isl_set_basic_sets
, METH_VARARGS
, NULL
},
122 {"isl_set_points", isl_set_points
, METH_VARARGS
, NULL
},
123 {"isl_vertices_vertices", isl_vertices_vertices
, METH_VARARGS
, NULL
},
124 {NULL
, NULL
, 0, NULL
}
127 static struct PyModuleDef _islhelpermodule
= {
128 PyModuleDef_HEAD_INIT
,
135 PyMODINIT_FUNC
PyInit__islhelper(void) {
137 m
= PyModule_Create(&_islhelpermodule
);
142 if (PyModule_AddObject(m
, "dim_set", PyLong_FromLong(isl_dim_set
)) == -1) {