I have the address of a function and also its "c-like" representation (from llvmlite, but this is not that important).
For a function, which adds up two double values and returns them the code would look like this: cfunc = CFUNCTYPE(c_double, c_double, c_double)(func_ptr)
That would work quite well, however my function's argument can vary in type and number. In python, this is solvable with some for arg in args
generator.
However i have no tool (or at least i found none) how to "convert" or parse my types to the ones of ctype.
The arguments are llvmlite-Type objects, so i have a c-like type representation availible.
My approach would be to create a dict, which can map llvmlite-Type objects, or the c-representation to the Type objects of ctypes. A little parser could help too.
Doesn't ctype provide something like this already? A magic function:
ctypes.magic("double") == ctypes.c_double
I am not bound to ctypes. I know CFFI exists, however i have 0 experience with it and as far as i look in the docs, i couldn't find even the basic solution for a single function address.
I am aware that my use case is rather rare, since both of those libraries are more concerned about libraries and not particular function's address.