Commit e35b483f authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Reduced number of JNI calls to getCore()

parent c41132f3
......@@ -470,9 +470,10 @@ class JavaTranslator(object):
classDict['isLinphoneFactory'] = _class.name.to_camel_case() == "Factory"
classDict['isLinphoneCore'] = _class.name.to_camel_case() == "Core"
hasCoreAccessor = _class.name.to_camel_case() in CORE_ACCESSOR_LIST
classDict['hasCoreAccessor'] = hasCoreAccessor
classDict['doc'] = _class.briefDescription.translate(self.docTranslator) if _class.briefDescription is not None else None
hasCoreAccessor = _class.name.to_camel_case() in CORE_ACCESSOR_LIST
for _property in _class.properties:
try:
classDict['methods'] += self.translate_property(_property, hasCoreAccessor)
......@@ -706,6 +707,7 @@ class JavaClass(object):
self.isLinphoneFactory = self._class['isLinphoneFactory']
self.isLinphoneCore = self._class['isLinphoneCore']
self.isNotLinphoneFactory = not self.isLinphoneFactory
self.hasCoreAccessor = self._class['hasCoreAccessor']
self.cName = 'Linphone' + _class.name.to_camel_case()
self.cPrefix = 'linphone_' + _class.name.to_snake_case()
self.packageName = package
......
......@@ -132,10 +132,12 @@ public {{#isLinphoneFactory}}abstract class{{/isLinphoneFactory}}{{#isNotLinphon
class {{classImplName}} {{#isLinphoneFactory}}extends{{/isLinphoneFactory}}{{#isNotLinphoneFactory}}implements{{/isNotLinphoneFactory}} {{className}} {
protected long nativePtr = 0;
protected Object userData = null;
protected Object userData = null;{{#hasCoreAccessor}}
protected Core core = null;{{/hasCoreAccessor}}
protected {{classImplName}}(long ptr) {
nativePtr = ptr;
nativePtr = ptr;{{#hasCoreAccessor}}
core = getCore();{{/hasCoreAccessor}}
}
{{#isLinphoneFactory}}
......@@ -182,7 +184,7 @@ class {{classImplName}} {{#isLinphoneFactory}}extends{{/isLinphoneFactory}}{{#is
private native {{return_native}} {{name}}({{native_params}});
@Override
synchronized public {{return}} {{name}}({{params}}) {{#exception}}throws CoreException{{/exception}} {
{{#hasCoreAccessor}}{{#isNotGetCore}}synchronized(getCore()) { {{/isNotGetCore}}{{/hasCoreAccessor}}
{{#hasCoreAccessor}}{{#isNotGetCore}}synchronized(core) { {{/isNotGetCore}}{{/hasCoreAccessor}}
{{#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}}{{#hasCoreAccessor}}{{#isNotGetCore}}
}{{/isNotGetCore}}{{/hasCoreAccessor}}
......
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