If I pass an array of structs to pointer, it fails with the error, "NotImplementedError: Type dtype('O') not implemented"
fromlpythonimportCPtr, c_p_pointer, p_c_pointer, dataclass, empty_c_void_p, pointerfromnumpyimportempty@dataclassclassFoo:
passdefmain() ->None:
foos: Foo[1] =empty(1, dtype=Foo)
pointer(foos)
main()
$ python /var/tmp/main.py
Traceback (most recent call last):
File "/var/tmp/main.py", line 13, in <module>
main()
File "/var/tmp/main.py", line 11, in main
pointer(foos)
File "/home/dylon/Workspace/lpython/src/runtime/lpython/lpython.py", line 446, in pointer
return x.ctypes.data_as(ctypes.POINTER(convert_numpy_dtype_to_ctype(x.dtype)))
File "/home/dylon/Workspace/lpython/src/runtime/lpython/lpython.py", line 291, in convert_numpy_dtype_to_ctype
raise NotImplementedError("Type %r not implemented" % arg)
NotImplementedError: Type dtype('O') not implemented
A solution seems to be to add the dtype to convert_numpy_dtype_to_ctype:
elifarg==np.voidorarg==np.dtype('O'):
returnctypes.c_void_p
If I pass an array of structs to
pointer, it fails with the error,"NotImplementedError: Type dtype('O') not implemented"A solution seems to be to add the dtype to
convert_numpy_dtype_to_ctype: