I've tried to cobble together code from: SWIG typemap uint8_t* from C/C++ to java.nio.ByteBuffer
To pass java.nio.ByteBuffer from java to std::array& for the C++ calls.
I'd like to do something similar with then answer from https://stackoverflow.com/users/168175/flexo in How to use SWIG to wrap std::function objects? for std::function (but I'm ok with the simple answer).
In particular I'd like a Java callback class that I can implement java for
std::function<void(const std::vector<uint8_t> &)>
to the C++ side,
uint32_t registerForEvent(const std::vector<uint8_t> &event, std::function<void(const std::vector<uint8_t> &)> process)
and have the c++ side call that function and have the java side be able to override/implement the call:
public class myCallback extends Callback {
public void call(java.nio.ByteBuffer data) {
/* do something with data */
}
}
I think I need some use of env->NewDirectByteBuffer(ptr,size) from something like SWIG typemap uint8_t* from C/C++ to java.nio.ByteBuffer initialized from the std::vector& sent from C++ to happen with the param/unpack/lvalref/forward.
Is there some sneaky way to make that happen with the generalized VA_ARGS macros? Or even just the oneshot for my simple case of the specific std::function: