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 bset
= isl_basic_set_finalize(bset
); // this instruction should not be required
40 n
= isl_basic_set_n_constraint(bset
);
42 PyErr_SetString(PyExc_RuntimeError
,
43 "an error occurred in isl_basic_set_n_constraint");
46 pointers
= PyList_New(n
);
47 if (pointers
== NULL
) {
50 list
= malloc(sizeof(pointer_list
));
53 return PyErr_NoMemory();
56 list
->pointers
= pointers
;
57 n
= isl_basic_set_foreach_constraint(bset
, pointer_list_append_constraint
,
61 PyErr_SetString(PyExc_RuntimeError
,
62 "an error occurred in isl_basic_set_foreach_constraint");
70 static int pointer_list_append_basic_set(isl_basic_set
*bset
, void *user
) {
74 list
= (pointer_list
*) user
;
75 value
= PyLong_FromVoidPtr(bset
);
79 PyList_SET_ITEM(list
->pointers
, list
->cursor
++, value
);
83 static PyObject
* isl_set_basic_sets(PyObject
*self
, PyObject
*args
) {
90 if (!PyArg_ParseTuple(args
, "l", &ptr
)) {
93 set
= (isl_set
*) ptr
;
94 n
= isl_set_n_basic_set(set
);
96 PyErr_SetString(PyExc_RuntimeError
,
97 "an error occurred in isl_set_n_basic_set");
100 pointers
= PyList_New(n
);
101 if (pointers
== NULL
) {
104 list
= malloc(sizeof(pointer_list
));
107 return PyErr_NoMemory();
110 list
->pointers
= pointers
;
111 n
= isl_set_foreach_basic_set(set
, pointer_list_append_basic_set
, list
);
114 PyErr_SetString(PyExc_RuntimeError
,
115 "an error occurred in isl_set_foreach_basic_set");
123 static PyMethodDef _islhelper_methods
[] = {
124 {"isl_basic_set_constraints", isl_basic_set_constraints
, METH_VARARGS
, NULL
},
125 {"isl_set_basic_sets", isl_set_basic_sets
, METH_VARARGS
, NULL
},
126 {NULL
, NULL
, 0, NULL
}
129 static struct PyModuleDef _islhelpermodule
= {
130 PyModuleDef_HEAD_INIT
,
137 PyMODINIT_FUNC
PyInit__islhelper(void) {
139 m
= PyModule_Create(&_islhelpermodule
);
144 if (PyModule_AddObject(m
, "dim_set", PyLong_FromLong(isl_dim_set
)) == -1) {