Commit a633dac8 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fix & workaround for Android's Java wrapper

parent 45a015e4
......@@ -391,6 +391,10 @@ class JavaTranslator(object):
methodDict['name'] = 'Java_' + self.jni_package + className.to_camel_case() + 'Impl_' + _method.name.to_camel_case(lower=True)
methodDict['notStatic'] = not static
methodDict['c_name'] = 'linphone_' + className.to_snake_case() + "_" + _method.name.to_snake_case()
if _method.name.to_snake_case() == 'create_core':
methodDict['c_name'] = 'linphone_' + className.to_snake_case() + "_" + 'create_core_3'
elif _method.name.to_snake_case() == 'create_core_with_config':
methodDict['c_name'] = 'linphone_' + className.to_snake_case() + "_" + 'create_core_with_config_3'
methodDict['returnObject'] = methodDict['hasReturn'] and type(_method.returnType) is AbsApi.ClassType
methodDict['returnClassName'] = self.translate_type(_method.returnType)
methodDict['isRealObjectArray'] = False
......@@ -435,7 +439,7 @@ class JavaTranslator(object):
classCName = 'Linphone' + arg.type.desc.name.to_camel_case()
if classCName[-8:] == 'Listener':
classCName = 'Linphone' + arg.type.desc.name.to_camel_case()[:-8] + 'Cbs'
methodDict['objects'].append({'object': argname, 'objectClassCName': classCName})
methodDict['objects'].append({'object': argname, 'objectClassCName': classCName, 'refCountable': arg.type.desc.refcountable})
methodDict['params_impl'] += 'c_' + argname
elif type(arg.type) is AbsApi.ListType:
......
......@@ -243,7 +243,7 @@ jobject get{{className}}(JNIEnv *env, {{classCName}} *cptr) {
if (up == NULL) {
jobj = env->NewObject({{cPrefix}}_class, {{cPrefix}}_constructor, (jlong)cptr);
belle_sip_object_data_set((belle_sip_object_t *)cptr, belle_sip_java_user_data_key, (void*)env->NewWeakGlobalRef(jobj), NULL);
{{cPrefix}}_ref(cptr);
{{#refCountable}}{{cPrefix}}_ref(cptr);{{/refCountable}}
} else {
jobj = env->NewLocalRef((jobject)up);
if (jobj == NULL) {
......@@ -252,7 +252,7 @@ jobject get{{className}}(JNIEnv *env, {{classCName}} *cptr) {
// takes implicit local ref
jobj = env->NewObject({{cPrefix}}_class, {{cPrefix}}_constructor, (jlong)cptr);
belle_sip_object_data_set((belle_sip_object_t *)cptr, belle_sip_java_user_data_key, (void*)env->NewWeakGlobalRef(jobj), NULL);
{{cPrefix}}_ref(cptr);
{{#refCountable}}{{cPrefix}}_ref(cptr);{{/refCountable}}
}
}
}
......@@ -266,7 +266,7 @@ void Java_{{jniPrefix}}{{classImplName}}_unref(JNIEnv* env, jobject thiz, jlong
if (wref) {
env->DeleteWeakGlobalRef(wref);
}
{{cPrefix}}_unref(cptr);
{{#refCountable}}{{cPrefix}}_unref(cptr);{{/refCountable}}
}
{{/objects}}
......
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