Commit 036cd8a5 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Always use objects in Java wrapper, JNI will take care of handling pointers

parent fac07d94
......@@ -191,9 +191,7 @@ class JavaTranslator(object):
methodDict['params'] += self.translate_argument(arg)
methodDict['native_params'] += self.translate_argument(arg, True)
methodDict['static_native_params'] += self.translate_argument(arg, True)
if type(arg.type) is AbsApi.ClassType:
methodDict['native_params_impl'] += '((' + self.translate_type(arg.type) + 'Impl)' + self.translate_argument_name( + ').nativePtr'
elif type(arg.type) is AbsApi.ListType:
if type(arg.type) is AbsApi.ListType:
if type(arg.type.containedTypeDesc) is AbsApi.ClassType:
methodDict['convertInputClassArrayToLongArray'] = True
methodDict['native_params_impl_list_param_name'] = self.translate_argument_name(
......@@ -35,4 +35,18 @@ static const char* GetStringUTFChars(JNIEnv* env, jstring string) {
static void ReleaseStringUTFChars(JNIEnv* env, jstring string, const char *cstring) {
if (string) env->ReleaseStringUTFChars(string, cstring);
static jlong GetObjectNativePtr(JNIEnv *env, jobject object) {
jclass objClass = env->GetObjectClass(object);
jfieldID nativePtrId = env->GetFieldID(objClass, "nativePtr", "J");
jlong nativePtr = env->GetLongField(object, nativePtrId);
return nativePtr;
static jlong SetObjectNativePtr(JNIEnv *env, jobject object, jlong ptr) {
jclass objClass = env->GetObjectClass(object);
jfieldID nativePtrId = env->GetFieldID(objClass, "nativePtr", "J");
env->SetLongField(object, nativePtrId, ptr);
return ptr;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment