36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
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('target/debug/libklamath_rs_ext.so')
|
|
clib = ffi.dlopen('target/debug/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)
|
|
|
|
|
|
|