Remove useless header in _isl.c
[linpy.git] / pypol / isl.py
1 import ctypes, ctypes.util
2
3 from . import _isl
4
5
6 __all__ = [
7 'Context',
8 'BasicSet',
9 ]
10
11
12 libisl = ctypes.CDLL(ctypes.util.find_library('isl'))
13
14 libisl.isl_printer_get_str.restype = ctypes.c_char_p
15 libisl.isl_dim_set = _isl.isl_dim_set
16
17
18 class IslObject:
19
20 __slots__ = (
21 '_ptr',
22 )
23
24 def __init__(self, ptr):
25 self._ptr = ptr
26
27 @property
28 def _as_parameter_(self):
29 return self._ptr
30
31
32 class Context(IslObject):
33
34 def __init__(self):
35 ptr = libisl.isl_ctx_alloc()
36 super().__init__(ptr)
37
38 #comment out so does not delete itself after being created
39 #def __del__(self):
40 # libisl.isl_ctx_free(self)
41
42 def __eq__(self, other):
43 if not isinstance(other, Context):
44 return False
45 return self._ptr == other._ptr
46
47
48 class BasicSet(IslObject):
49
50 def __str__(self):
51 ls = libisl.isl_basic_set_get_local_space(self)
52 ctx = libisl.isl_local_space_get_ctx(ls)
53 p = libisl.isl_printer_to_str(ctx)
54 p = libisl.isl_printer_print_basic_set(p, self)
55 string = libisl.isl_printer_get_str(p).decode()
56 return string
57
58 def __del__(self):
59 libisl.isl_basic_set_free(self)
60
61 def constraints(self):
62 return _isl.isl_basic_set_constraints(self._ptr)