Commit 8882c8e2 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Improved Java's genwrapper to handle LinphoneBuffer

parent b65fcaa2
......@@ -136,6 +136,8 @@ class JavaTranslator(object):
inttype = 'u' + inttype
if t.isref:
inttype = inttype + ' *'
if t.isconst:
inttype = 'const ' + inttype
return inttype
elif _type == 'boolean':
return 'bool_t'
......@@ -206,6 +208,10 @@ class JavaTranslator(object):
return 'jstring'
return 'String'
elif _type.name == 'integer':
if _type.size is not None and _type.isref:
if jni:
return 'jbyteArray'
return 'byte[]'
if jni:
return 'jint'
return 'int'
......@@ -344,9 +350,10 @@ class JavaTranslator(object):
methodDict['return'] = self.translate_type(_method.returnType, jni=True, isReturn=True)
methodDict['hasListReturn'] = methodDict['return'] == 'jobjectArray'
methodDict['hasReturn'] = not methodDict['return'] == 'void' and not methodDict['hasListReturn']
methodDict['hasByteArrayReturn'] = methodDict['return'] == 'jbyteArray'
methodDict['hasReturn'] = not methodDict['return'] == 'void' and not methodDict['hasListReturn'] and not methodDict['hasByteArrayReturn']
methodDict['hasStringReturn'] = methodDict['return'] == 'jstring'
methodDict['hasNormalReturn'] = not methodDict['hasListReturn'] and not methodDict['hasStringReturn']
methodDict['hasNormalReturn'] = not methodDict['hasListReturn'] and not methodDict['hasStringReturn'] and not methodDict['hasByteArrayReturn']
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()
......@@ -354,6 +361,7 @@ class JavaTranslator(object):
methodDict['returnClassName'] = self.translate_type(_method.returnType)
methodDict['isRealObjectArray'] = False
methodDict['isStringObjectArray'] = False
methodDict['c_type_return'] = self.translate_as_c_base_type(_method.returnType)
if methodDict['hasListReturn']:
if type(_method.returnType) is AbsApi.BaseType and _method.returnType.name == 'string_array':
......@@ -731,7 +739,7 @@ class GenWrapper(object):
project.initFromDir(xmldir)
project.check()
self.parser = AbsApi.CParser(project, ['LinphoneBuffer'])
self.parser = AbsApi.CParser(project)
self.parser.functionBl = \
['linphone_vcard_get_belcard',\
'linphone_core_get_current_vtable',\
......
......@@ -326,7 +326,14 @@ jobject {{jni_package}}CoreImpl_getMediastreamerFactory(JNIEnv *env, jobject thi
}
list = bctbx_list_next(list);
}
{{/hasListReturn}}{{#hasStringReturn}}
{{/hasListReturn}}{{#hasByteArrayReturn}}
{{c_type_return}} jni_result = {{c_name}}({{#notStatic}}cptr{{/notStatic}}{{params_impl}});
if (!jni_result) return NULL;
size_t jni_result_length = strlen((const char *)jni_result);
jbyteArray array = env->NewByteArray((int)jni_result_length);
env->SetByteArrayRegion(array, 0, (int)jni_result_length, (const jbyte*)jni_result);
return array;
{{/hasByteArrayReturn}}{{#hasStringReturn}}
const char *c_string = {{c_name}}({{#notStatic}}cptr{{/notStatic}}{{params_impl}}){{#returnObject}}){{/returnObject}};
jstring jni_result = (c_string != NULL) ? env->NewStringUTF(c_string) : NULL;
{{/hasStringReturn}}{{#hasNormalReturn}}
......
......@@ -73,6 +73,7 @@ eval "$SED_START 's/LinphoneCoreFactory/Factory/g' $SED_END"
eval "$SED_START 's/LinphoneAccountCreator/AccountCreator/g' $SED_END"
eval "$SED_START 's/LinphoneAddress/Address/g' $SED_END"
eval "$SED_START 's/LinphoneAuthInfo/AuthInfo/g' $SED_END"
eval "$SED_START 's/LinphoneBuffer/Buffer/g' $SED_END"
eval "$SED_START 's/LinphoneCallLog/CallLog/g' $SED_END"
eval "$SED_START 's/LinphoneCallParams/CallParams/g' $SED_END"
eval "$SED_START 's/LinphoneCallStats/CallStats/g' $SED_END"
......
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