Fix methods Domain._sort_polygon_2d(), Domain._sort_polygon_3d()
[linpy.git] / pypol / islhelper.py
1 import ctypes, ctypes.util
2
3 from . import _islhelper
4 from ._islhelper import *
5
6
7 __all__ = [
8 'libisl',
9 'isl_version',
10 'mainctx',
11 'isl_val_to_int',
12 'isl_basic_set_to_str', 'isl_basic_set_constraints',
13 'isl_set_to_str', 'isl_set_basic_sets',
14 'isl_set_points',
15 'isl_vertices_vertices',
16 'isl_multi_aff_to_str',
17 ]
18
19
20 libisl = ctypes.CDLL(ctypes.util.find_library('isl'))
21 libisl.isl_dim_set = _islhelper.dim_set
22
23 libisl.isl_version.restype = ctypes.c_char_p
24 isl_version = libisl.isl_version().decode().strip()[len('isl-'):]
25
26
27 mainctx = libisl.isl_ctx_alloc()
28
29
30 libisl.isl_printer_get_str.restype = ctypes.c_char_p
31
32 def isl_val_to_int(islval):
33 islpr = libisl.isl_printer_to_str(mainctx)
34 islpr = libisl.isl_printer_print_val(islpr, islval)
35 string = libisl.isl_printer_get_str(islpr).decode()
36 return int(string)
37
38 def isl_basic_set_to_str(islbset):
39 islpr = libisl.isl_printer_to_str(mainctx)
40 islpr = libisl.isl_printer_print_basic_set(islpr, islbset)
41 string = libisl.isl_printer_get_str(islpr).decode()
42 return string
43
44 def isl_set_to_str(islset):
45 islpr = libisl.isl_printer_to_str(mainctx)
46 islpr = libisl.isl_printer_print_set(islpr, islset)
47 string = libisl.isl_printer_get_str(islpr).decode()
48 return string
49
50 def isl_multi_aff_to_str(islmaff):
51 islpr = libisl.isl_printer_to_str(mainctx)
52 islpr = libisl.isl_printer_print_multi_aff(islpr, islmaff)
53 string = libisl.isl_printer_get_str(islpr).decode()
54 return string