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 PyMethodDef _islhelper_methods
[] = {
123 {"isl_basic_set_constraints", isl_basic_set_constraints
, METH_VARARGS
, NULL
},
124 {"isl_set_basic_sets", isl_set_basic_sets
, METH_VARARGS
, NULL
},
125 {NULL
, NULL
, 0, NULL
}
128 static struct PyModuleDef _islhelpermodule
= {
129 PyModuleDef_HEAD_INIT
,
136 PyMODINIT_FUNC
PyInit__islhelper(void) {
138 m
= PyModule_Create(&_islhelpermodule
);
143 if (PyModule_AddObject(m
, "dim_set", PyLong_FromLong(isl_dim_set
)) == -1) {