|
| 1 | +from ctypes import * |
| 2 | + |
| 3 | +__cuBoolLib = 0 |
| 4 | + |
| 5 | +class CuBoolInstanceDesc(Structure): |
| 6 | + _fields_ = [] |
| 7 | + |
| 8 | +class CuBoolInstance(Structure): |
| 9 | + _fields_ = [] |
| 10 | + |
| 11 | +class CuBoolMatrix(Structure): |
| 12 | + _fields_ = [] |
| 13 | + |
| 14 | +__instance = CuBoolInstance() |
| 15 | +__instanceDesc = CuBoolInstanceDesc() |
| 16 | + |
| 17 | +def CuBoolLibLoad(path: str): |
| 18 | + global cuBoolLib |
| 19 | + cuBoolLib = cdll.LoadLibrary(path) |
| 20 | + |
| 21 | +def CuBool_Instance_New(): |
| 22 | + global __cuBoolLib |
| 23 | + global __instance |
| 24 | + global __instanceDesc |
| 25 | + __cuBoolLib.CuBool_Instance_New.restype = c_int |
| 26 | + __cuBoolLib.CuBool_Instance_New.argtypes = [POINTER(CuBoolInstanceDesc), |
| 27 | + POINTER(CuBoolInstance)] |
| 28 | + status = __cuBoolLib.CuBool_Instance_New(pointer(__instanceDesc), pointer(__instance)) |
| 29 | + print("Status of creating instance is", status) |
| 30 | + |
| 31 | +def CuBool_Instance_Free(): |
| 32 | + global instance |
| 33 | + __cuBoolLib.CuBool_Instance_Free.restype = c_int |
| 34 | + __cuBoolLib.CuBool_Instance_Free.argtypes = [CuBoolInstance] |
| 35 | + status = __cuBoolLib.CuBool_Instance_Free(__instance) |
| 36 | + print("Status of deleting instance is", status) |
| 37 | + |
| 38 | +def CuBool_Matrix_New(nrows: c_int, ncols: c_int): |
| 39 | + global __cuBoolLib |
| 40 | + global __instance |
| 41 | + |
| 42 | + matrix = CuBoolMatrix() |
| 43 | + __cuBoolLib.CuBool_Matrix_New.restype = c_int |
| 44 | + __cuBoolLib.CuBool_Matrix_New.argtypes = [CuBoolInstance, |
| 45 | + POINTER(CuBoolMatrix), |
| 46 | + c_int, |
| 47 | + c_int] |
| 48 | + status = __cuBoolLib.CuBool_Matrix_New(__instance, pointer(matrix), nrows, ncols) |
| 49 | + print("Status of creating matrix is", status) |
| 50 | + return matrix |
0 commit comments