first working attempt
This commit is contained in:
parent
4aa14c4914
commit
e2ba1390c6
8 changed files with 165 additions and 55 deletions
35
test.py
Normal file
35
test.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import ctypes
|
||||
import pyarrow
|
||||
from pyarrow.cffi import ffi
|
||||
|
||||
#c_schema = ffi.new('struct ArrowSchema*')
|
||||
#c_array = ffi.new('struct ArrowArray*')
|
||||
#ptr_schema = int(ffi.cast('uintptr_t', c_schema))
|
||||
#ptr_array = int(ffi.cast('uintptr_t', c_array))
|
||||
|
||||
|
||||
path = '/home/jan/projects/masque/test.gds'
|
||||
|
||||
#clib = ctypes.CDLL('./libklamath_rs_ext.so')
|
||||
clib = ffi.dlopen('./libklamath_rs_ext.so')
|
||||
|
||||
|
||||
ret_ptr_array = ffi.new('struct ArrowArray[]', 1)
|
||||
ret_ptr_schema = ffi.new('struct ArrowSchema[]', 1)
|
||||
ffi.cdef('void read_path(char* path, struct ArrowArray* array, struct ArrowSchema* schema);')
|
||||
print(f'{ret_ptr_array[0]=}, {ret_ptr_schema[0]=}')
|
||||
|
||||
clib.read_path(path.encode(), ret_ptr_array, ret_ptr_schema)
|
||||
|
||||
ptr_schema = int(ffi.cast('uintptr_t', ret_ptr_schema))
|
||||
ptr_array = int(ffi.cast('uintptr_t', ret_ptr_array))
|
||||
|
||||
|
||||
print(f'{ret_ptr_array[0]=}, {ret_ptr_schema[0]=}')
|
||||
print(f'python {ptr_array=:x} {ptr_schema=:x}')
|
||||
#print(f'{ret_ptr_array[0].buffers=} {ret_ptr_schema[0][0]=}')
|
||||
|
||||
arr_new = pyarrow.Array._import_from_c(ptr_array, ptr_schema)
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue