diff --git a/wrappers/java/genwrapper.py b/wrappers/java/genwrapper.py index 9a4d28949..51465d7da 100644 --- a/wrappers/java/genwrapper.py +++ b/wrappers/java/genwrapper.py @@ -483,9 +483,19 @@ class JavaTranslator(object): methodDict['callbackName'] = methodDict['cPrefix'] + '_' + _method.name.to_snake_case() methodDict['jname'] = _method.name.to_camel_case(lower=True) methodDict['return'] = self.translate_as_c_base_type(_method.returnType) + methodDict['jniUpcallMethod'] = 'CallVoidMethod' + methodDict['isJniUpcallBasicType'] = False + methodDict['isJniUpcallObject'] = False if type(_method.returnType) is AbsApi.ClassType: methodDict['return'] += '*' - methodDict['returnIfFail'] = '' if methodDict['return'] == 'void' else ' NULL' #TODO + methodDict['jniUpcallMethod'] = 'CallObjectMethod' + methodDict['isJniUpcallObject'] = True + methodDict['jniUpcallType'] = 'jobject' + elif type(_method.returnType) is AbsApi.BaseType: + methodDict['jniUpcallMethod'] = 'CallIntMethod' + methodDict['jniUpcallType'] = self.translate_type(_method.returnType, jni=True) + methodDict['isJniUpcallBasicType'] = True + methodDict['returnIfFail'] = '' if methodDict['return'] == 'void' else ' NULL' methodDict['hasReturn'] = not methodDict['return'] == 'void' methodDict['isSingleListener'] = not _class.multilistener methodDict['isMultiListener'] = _class.multilistener @@ -531,7 +541,12 @@ class JavaTranslator(object): if (methodDict['return'] == 'void'): methodDict['jparams'] += 'V' else: - pass #TODO + if type(_method.returnType) is AbsApi.ClassType: + methodDict['jparams'] += 'L' + self.jni_path + _method.returnType.desc.name.to_camel_case() + ';' + elif type(_method.returnType) is AbsApi.BaseType: + methodDict['jparams'] += self.translate_java_jni_base_type_name(_method.returnType.name) + else: + pass #TODO return methodDict diff --git a/wrappers/java/jni.mustache b/wrappers/java/jni.mustache index 607f7af64..bb45e503d 100644 --- a/wrappers/java/jni.mustache +++ b/wrappers/java/jni.mustache @@ -210,7 +210,16 @@ static {{return}} {{callbackName}}({{params}}) { jstring j_{{stringName}} = {{stringName}} ? env->NewStringUTF({{stringName}}) : NULL; {{/jstrings}} - env->CallVoidMethod(jlistener, jcallback, {{params_impl}}); + {{#hasReturn}}{{jniUpcallType}} jni_upcall_result = {{/hasReturn}}env->{{jniUpcallMethod}}(jlistener, jcallback, {{params_impl}}); + {{#hasReturn}} + {{#isJniUpcallObject}} + {{return}} c_upcall_result = NULL; + if (jni_upcall_result) c_upcall_result = ({{return}})GetObjectNativePtr(env, jni_upcall_result); + {{/isJniUpcallObject}} + {{#isJniUpcallBasicType}} + {{return}} c_upcall_result = ({{return}}) jni_upcall_result; + {{/isJniUpcallBasicType}} + {{/hasReturn}} {{#jobjects}} if (j_{{objectName}}) { @@ -225,7 +234,7 @@ static {{return}} {{callbackName}}({{params}}) { handle_possible_java_exception(env, jlistener); {{#hasReturn}} - return 0; + return c_upcall_result; {{/hasReturn}} } diff --git a/wrappers/java/migration.sh b/wrappers/java/migration.sh index 106156d2c..3d826c470 100644 --- a/wrappers/java/migration.sh +++ b/wrappers/java/migration.sh @@ -304,13 +304,10 @@ eval "$SED_START 's/linkPhoneNumberWithAccount()/linkAccount()/g' $SED_END" eval "$SED_START 's/zoomVideo(/zoom(/g' $SED_END" eval "$SED_START 's/mLc.setCpuCount(/\/\/mLc.setCpuCount(/g' $SED_END" -#Core.setCpuCount() => Not needed anymore, can be removed # TODO #Tunnel, TunnelConfig -#LinphoneBuffer #AccountCreator.updatePassword => What to do ? # XmlRpcRequest and XmlRpcSession constructors -# Callbacks with return like chat messages' file transfer #Android specifics not wrapped automatically #Core.startEchoCalibration @@ -337,6 +334,8 @@ eval "$SED_START 's/mLc.setCpuCount(/\/\/mLc.setCpuCount(/g' $SED_END" # setPrimaryContact only takes one String argument # AdaptiveRateAlgorithm was an enum, now is nothing # createAddress(userName,domain,null); no longer exists +# Buffer.setContent now takes the size as second parameter +# ChatMessageListener onFileTransferSend now returns the Buffer instead of having it as part of his arguments # # Factory #Factory.createLpConfigFromString => Config.newFromBuffer