Skip to content

Commit 6b06243

Browse files
committed
Test commit
- added first version of python wrapper
1 parent 4a47151 commit 6b06243

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

python/pycubool/cubool.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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

python/pycubool/userApp.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import cubool
2+
import ctypes
3+
4+
print("Enter path to lib")
5+
path_to_lib = input()
6+
7+
cubool.CuBoolLibLoad(path_to_lib)
8+
cubool.CuBool_Instance_New()
9+
10+
test_matrix = cubool.CuBool_Matrix_New(ctypes.c_int(100), ctypes.c_int(100))
11+
12+
cubool.CuBool_Instance_Free()

0 commit comments

Comments
 (0)