Commit ef782426 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Handled in Java's genwrapper callbacks with return value

parent 0c9100d5
......@@ -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
......
......@@ -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}}
}
......
......@@ -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
......
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