mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
Improved way to get array of objects in java wrapper
This commit is contained in:
parent
5a009ff9d5
commit
fac07d9429
2 changed files with 4 additions and 18 deletions
|
|
@ -84,6 +84,8 @@ class JavaTranslator(object):
|
|||
|
||||
def translate_type(self, _type, native=False, jni=False):
|
||||
if type(_type) is AbsApi.ListType:
|
||||
if jni:
|
||||
return 'jobjectArray'
|
||||
ptrtype = ''
|
||||
if type(_type.containedTypeDesc) is AbsApi.ClassType:
|
||||
ptrtype = self.translate_type(_type.containedTypeDesc, native)
|
||||
|
|
@ -99,9 +101,7 @@ class JavaTranslator(object):
|
|||
return ptrtype + '[]'
|
||||
|
||||
elif type(_type) is AbsApi.ClassType:
|
||||
if native:
|
||||
return 'Object'
|
||||
elif jni:
|
||||
if jni:
|
||||
return 'jobject'
|
||||
return _type.desc.name.to_camel_case()
|
||||
elif type(_type) is AbsApi.EnumType:
|
||||
|
|
@ -172,10 +172,6 @@ class JavaTranslator(object):
|
|||
methodDict['return_keyword'] = '' if methodDict['return'] == 'void' else 'return '
|
||||
|
||||
methodDict['convertInputClassArrayToLongArray'] = False
|
||||
methodDict['convertOutputClassArrayToLongArray'] = type(_method.returnType) is AbsApi.ListType and type(_method.returnType.containedTypeDesc) is AbsApi.ClassType
|
||||
if methodDict['convertOutputClassArrayToLongArray']:
|
||||
methodDict['native_params_impl_list_param_name'] = 'classArray'
|
||||
methodDict['native_params_impl_list_param_type'] = self.translate_type(_method.returnType.containedTypeDesc)
|
||||
|
||||
methodDict['name'] = _method.name.to_camel_case(lower=True)
|
||||
methodDict['exception'] = self.throws_exception(_method.returnType)
|
||||
|
|
@ -210,7 +206,7 @@ class JavaTranslator(object):
|
|||
else:
|
||||
methodDict['native_params_impl'] += self.translate_argument_name(arg.name)
|
||||
|
||||
methodDict['classicMethod'] = not methodDict['convertInputClassArrayToLongArray'] and not methodDict['convertOutputClassArrayToLongArray']
|
||||
methodDict['classicMethod'] = not methodDict['convertInputClassArrayToLongArray']
|
||||
methodDict['deprecated'] = _method.deprecated
|
||||
methodDict['doc'] = self.docTranslator.translate(_method.briefDescription) if _method.briefDescription is not None else None
|
||||
|
||||
|
|
|
|||
|
|
@ -135,16 +135,6 @@ class {{classImplName}} implements {{className}} {
|
|||
}
|
||||
{{name}}(nativePtr{{native_params_impl}});
|
||||
{{/convertInputClassArrayToLongArray}}
|
||||
{{#convertOutputClassArrayToLongArray}}
|
||||
long[] longArray = {{name}}(nativePtr{{native_params_impl}});
|
||||
if (longArray == null) return null;
|
||||
|
||||
{{native_params_impl_list_param_type}}[] classArray = new {{native_params_impl_list_param_type}}[longArray.length];
|
||||
for (int i=0; i < longArray.length; i++) {
|
||||
classArray[i] = new {{native_params_impl_list_param_type}}Impl(longArray[i]);
|
||||
}
|
||||
return classArray;
|
||||
{{/convertOutputClassArrayToLongArray}}
|
||||
{{#classicMethod}}
|
||||
{{#exception}}int exceptionResult = {{/exception}}{{return_keyword}}{{#enumCast}}{{return}}.fromInt({{/enumCast}}{{#classCast}}({{return}}){{/classCast}}{{name}}(nativePtr{{native_params_impl}}){{#enumCast}}){{/enumCast}};
|
||||
{{#exception}}if (exceptionResult != 0) throw new CoreException("{{name}} returned value " + exceptionResult){{/exception}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue