[Fwd: Re: Some troubles I met while building PPL.]


Yuriy Taraday yorik.sar@gmail.com wrote: [...]
By the way, in our project we use Java interface and we needed the value of PPL_Object.ptr to use in JNI library. May be, it should be somehow accessible from the outside? It might be useful for extending PPL and using it in conjunction with other libraries.
Well, I am a bit reluctant in making this publicly accessible, since it is an implementation detail and we would like to have maximum freedom about it (for instance, currently not all PPL Java objects are derived from PPL_Object).
Anyway, if you are working at the JNI level and you don't mind having to fix your code whenever we might decide to change the implementation, then you should be able to extract the C++ pointer in the same way we currently do:
[code snippet from interfaces/Java/jni/ppl_java_globals.cc] ================= MIP_Problem* mip = reinterpret_cast<MIP_Problem*>(get_ptr(env, j_this_mip_problem)); =================
Here we use the helper function `get_ptr' function from ppl_java_common.defs.hh:
//! Returns a pointer to the C++ object wrapped by \p ppl_object. void* get_ptr(JNIEnv* env, const jobject& ppl_object);
to obtain a void*, which is then immediately cast to the appropriate C++ pointer type.
Regards, Enea Zaffanella.
participants (2)
-
Abramo Bagnara
-
Enea Zaffanella