3 #include <isl/constraint.h>
12 typedef struct pointer_list pointer_list
;
15 static int pointer_list_append_constraint(isl_constraint
*c
, void *user
) {
19 list
= (pointer_list
*) user
;
20 value
= PyLong_FromVoidPtr(c
);
24 PyList_SET_ITEM(list
->pointers
, list
->cursor
++, value
);
28 static PyObject
* isl_basic_set_constraints(PyObject
*self
, PyObject
* args
) {
35 if (!PyArg_ParseTuple(args
, "l", &ptr
)) {
38 bset
= (isl_basic_set
*) ptr
;
39 n
= isl_basic_set_n_constraint(bset
);
41 PyErr_SetString(PyExc_RuntimeError
,
42 "an error occurred in isl_basic_set_n_constraint");
45 pointers
= PyList_New(n
);
46 if (pointers
== NULL
) {
49 list
= malloc(sizeof(pointer_list
));
52 return PyErr_NoMemory();
55 list
->pointers
= pointers
;
56 n
= isl_basic_set_foreach_constraint(bset
, pointer_list_append_constraint
,
60 PyErr_SetString(PyExc_RuntimeError
,
61 "an error occurred in isl_basic_set_foreach_constraint");
69 static int pointer_list_append_basic_set(isl_basic_set
*bset
, void *user
) {
73 list
= (pointer_list
*) user
;
74 value
= PyLong_FromVoidPtr(bset
);
78 PyList_SET_ITEM(list
->pointers
, list
->cursor
++, value
);
82 static PyObject
* isl_set_basic_sets(PyObject
*self
, PyObject
*args
) {
89 if (!PyArg_ParseTuple(args
, "l", &ptr
)) {
92 set
= (isl_set
*) ptr
;
93 n
= isl_set_n_basic_set(set
);
95 PyErr_SetString(PyExc_RuntimeError
,
96 "an error occurred in isl_set_n_basic_set");
99 pointers
= PyList_New(n
);
100 if (pointers
== NULL
) {
103 list
= malloc(sizeof(pointer_list
));
106 return PyErr_NoMemory();
109 list
->pointers
= pointers
;
110 n
= isl_set_foreach_basic_set(set
, pointer_list_append_basic_set
, list
);
113 PyErr_SetString(PyExc_RuntimeError
,
114 "an error occurred in isl_set_foreach_basic_set");
122 static int pointer_list_append_point(isl_point
*point
, void *user
) {
123 PyObject
*pointers
, *value
;
125 pointers
= (PyObject
*) user
;
126 value
= PyLong_FromVoidPtr(point
);
130 return PyList_Append(pointers
, value
);
133 static PyObject
* isl_set_points(PyObject
*self
, PyObject
*args
) {
139 if (!PyArg_ParseTuple(args
, "l", &ptr
)) {
142 set
= (isl_set
*) ptr
;
143 pointers
= PyList_New(0);
144 if (pointers
== NULL
) {
147 n
= isl_set_foreach_point(set
, pointer_list_append_point
, pointers
);
149 PyErr_SetString(PyExc_RuntimeError
,
150 "an error occurred in isl_set_foreach_point");
158 static PyMethodDef _islhelper_methods
[] = {
159 {"isl_basic_set_constraints", isl_basic_set_constraints
, METH_VARARGS
, NULL
},
160 {"isl_set_basic_sets", isl_set_basic_sets
, METH_VARARGS
, NULL
},
161 {"isl_set_points", isl_set_points
, METH_VARARGS
, NULL
},
162 {NULL
, NULL
, 0, NULL
}
165 static struct PyModuleDef _islhelpermodule
= {
166 PyModuleDef_HEAD_INIT
,
173 PyMODINIT_FUNC
PyInit__islhelper(void) {
175 m
= PyModule_Create(&_islhelpermodule
);
180 if (PyModule_AddObject(m
, "dim_set", PyLong_FromLong(isl_dim_set
)) == -1) {