Hi all,
I'd like to call a Julia function from C++. This Julia function takes another Julia function as an argument (a callback function). I'd like to write this callback function entirely in C++ too, and pass it directly to Julia, without declaring a global name for it in Julia's name space (like how ints, floats, etc. are passed from C++ to Julia wo creating top-level names for them in Julia). Presumably the arguments to my C++ implementation of the callback function will havejl_value_t * as their types.
Can anyone show me how to do this?
I tried posting this question on stackoverflow originally but I didn't get an answer.
Thanks much!
Jeff
julia> entry_ptr = cfunction( (x, ptr) -> ccall(ptr, Int, (Int,), x), Int, (Int, Ptr{Void}) )Ptr{Void} @0x0000000317ee4c60julia> cb_ptr = cfunction( y -> y^2, Int, (Int,))Ptr{Void} @0x0000000317ee80c0julia> myf(x) = ccall(entry_ptr, Int, (Int, Ptr{Void}), x, cb_ptr)myf (generic function with 1 method)julia> myf(4)16