Commit 12df1381 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Simplified java wrapper

parent 036cd8a5
......@@ -191,20 +191,11 @@ class JavaTranslator(object):
methodDict['params'] += self.translate_argument(arg)
methodDict['native_params'] += self.translate_argument(arg, True)
methodDict['static_native_params'] += self.translate_argument(arg, True)
if type(arg.type) is AbsApi.ListType:
if type(arg.type.containedTypeDesc) is AbsApi.ClassType:
methodDict['convertInputClassArrayToLongArray'] = True
methodDict['native_params_impl_list_param_name'] = self.translate_argument_name(arg.name)
methodDict['native_params_impl_list_param_type'] = self.translate_type(arg.type.containedTypeDesc) + 'Impl'
methodDict['native_params_impl'] += 'longArray'
else:
methodDict['native_params_impl'] += self.translate_argument_name(arg.name)
elif type(arg.type) is AbsApi.EnumType:
if type(arg.type) is AbsApi.EnumType:
methodDict['native_params_impl'] += self.translate_argument_name(arg.name) + '.toInt()'
else:
methodDict['native_params_impl'] += self.translate_argument_name(arg.name)
methodDict['classicMethod'] = not methodDict['convertInputClassArrayToLongArray']
methodDict['deprecated'] = _method.deprecated
methodDict['doc'] = self.docTranslator.translate(_method.briefDescription) if _method.briefDescription is not None else None
......
......@@ -128,17 +128,8 @@ class {{classImplName}} implements {{className}} {
{{#methods}}
private native {{return_native}} {{name}}({{native_params}});
public {{return}} {{name}}({{params}}) {{#exception}}throws CoreException{{/exception}} {
{{#convertInputClassArrayToLongArray}}
long[] longArray = new long[{{native_params_impl_list_param_name}}.length];
for (int i=0; i < {{native_params_impl_list_param_name}}.length; i++) {
longArray[i] = (({{native_params_impl_list_param_type}}){{native_params_impl_list_param_name}}[i]).nativePtr;
}
{{name}}(nativePtr{{native_params_impl}});
{{/convertInputClassArrayToLongArray}}
{{#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}}
{{/classicMethod}}
}
{{/methods}}
......
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