1from ctypes import *
2
3isl = cdll.LoadLibrary("libisl.so")
4libc = cdll.LoadLibrary("libc.so.6")
5
6class Error(Exception):
7    pass
8
9class Context:
10    defaultInstance = None
11
12    def __init__(self):
13        ptr = isl.isl_ctx_alloc()
14        self.ptr = ptr
15
16    def __del__(self):
17        isl.isl_ctx_free(self)
18
19    def from_param(self):
20        return self.ptr
21
22    @staticmethod
23    def getDefaultInstance():
24        if Context.defaultInstance == None:
25            Context.defaultInstance = Context()
26        return Context.defaultInstance
27
28isl.isl_ctx_alloc.restype = c_void_p
29isl.isl_ctx_free.argtypes = [Context]
30