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

Started JAVA wrapper

parent 2c67a76d
......@@ -191,3 +191,8 @@ class SandcastleCSharpTranslator(Translator):
if len(lines) > 0:
lines.insert(0, '<summary>')
lines.append('</summary>')
class SandcastleJavaTranslator(Translator):
def _tag_as_brief(self, lines):
pass
......@@ -566,7 +566,7 @@ def render(renderer, item, path):
os.unlink(tmppath)
def main():
argparser = argparse.ArgumentParser(description='Generate source files for the C++ wrapper')
argparser = argparse.ArgumentParser(description='Generate source files for the C# wrapper')
argparser.add_argument('xmldir', type=str, help='Directory where the XML documentation of the Linphone\'s API generated by Doxygen is placed')
argparser.add_argument('-o --output', type=str, help='the directory where to generate the source files', dest='outputdir', default='.')
argparser.add_argument('-n --name', type=str, help='the name of the genarated source file', dest='outputfile', default='LinphoneWrapper.cs')
......
############################################################################
# CMakeLists.txt
# Copyright (C) 2017 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
add_custom_command(OUTPUT linphone_jni.cc
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/genwrapper.py" "${PROJECT_BINARY_DIR}/coreapi/help/doc/doxygen/xml"
DEPENDS ${PROJECT_SOURCE_DIR}/tools/genapixml.py
${PROJECT_SOURCE_DIR}/tools/metadoc.py
${PROJECT_SOURCE_DIR}/tools/abstractapi.py
genwrapper.py
wrapper_impl.mustache
linphone-doc
"${PROJECT_BINARY_DIR}/coreapi/help/doc/doxygen/xml/index.xml"
)
add_custom_target(linphonej ALL DEPENDS linphone_jni.cc)
#install(FILES ${CMAKE_CURRENT_BINARY_DIR}/linphone_jni.cc
# DESTINATION ${CMAKE_INSTALL_DATADIR}/linphonej
#)
This diff is collapsed.
/*
{{className}}.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package {{packageName}}
{{#imports}}
import {{import}}
{{/imports}}
{{#isLinphoneFactory}}
import org.linphone.mediastream.Version;
{{/isLinphoneFactory}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
public interface {{className}} {
{{#enums}}
enum {{className}} {
{{#values}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
{{name}}({{value}}){{commarorsemicolon}}
{{/values}}
protected final int mValue;
private {{className}} (int value) {
mValue = value;
}
static protected {{className}} fromInt(int value) throws CoreException {
switch(value) {
{{#values}}
case {{value}}: return {{name}};
{{/values}}
default:
throw new CoreException("Unhandled enum value " + value + " for {{className}}");
}
}
};
{{/enums}}
{{#isLinphoneFactory}}
{{/isLinphoneFactory}}
{{#methods}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
{{#deprecated}}@deprecated
{{/deprecated}}public {{return}} {{name}}({{params}}){{#exception}} throws CoreException{{/exception}};
{{/methods}}
{{#staticMethods}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
public {{return}} {{name}}({{params}}){{#exception}} throws CoreException{{/exception}};
{{/staticMethods}}
}
class {{classImplName}} implements {{className}} {
protected long nativePtr = 0;
{{#isLinphoneFactory}}
private static boolean loadOptionalLibrary(String s) {
try {
System.loadLibrary(s);
return true;
} catch (Throwable e) {
android.util.Log.w("LinphoneCoreFactoryImpl", "Unable to load optional library " + s + ": " +e.getMessage());
}
return false;
}
static {
System.loadLibrary("gnustl_shared");
loadOptionalLibrary("ffmpeg-linphone");
System.loadLibrary("bctoolbox");
System.loadLibrary("ortp");
System.loadLibrary("mediastreamer_base");
System.loadLibrary("mediastreamer_voip");
System.loadLibrary("linphone");
Version.dumpCapabilities();
}
{{/isLinphoneFactory}}
{{#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}}
{{#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}}
{{return_keyword}}{{name}}(nativePtr{{native_params_impl}});
{{/classicMethod}}
}
{{/methods}}
{{#staticMethods}}
@Override
private native {{return_native}} {{name}}({{static_native_params}});
{{/staticMethods}}
}
\ No newline at end of file
/*
{{className}}.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package {{packageName}}
{{#imports}}
import {{import}}
{{/imports}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
public enum {{className}} {
{{#values}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
{{name}}({{value}}){{commarorsemicolon}}
{{/values}}
protected final int mValue;
private {{className}} (int value) {
mValue = value;
}
static protected {{className}} fromInt(int value) throws CoreException {
switch(value) {
{{#values}}
case {{value}}: return {{name}};
{{/values}}
default:
throw new CoreException("Unhandled enum value " + value + " for {{className}}");
}
}
}
\ No newline at end of file
/*
{{className}}.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package {{packageName}}
{{#imports}}
import {{import}}
{{/imports}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
static public class {{className}} {
static private Vector<{{className}}> values = new Vector<{{className}}>();
{{#values}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
static public {{className}} {{name}} = new {{className}}({{value}}, {{name}});
{{/values}}
protected final int mValue;
private final String mStringValue;
private {{className}}(int value, String stringValue) {
mValue = value;
values.addElement(this);
mStringValue = stringValue;
}
public static {{className}} fromInt(int value) {
for (int i = 0; i < values.size(); i++) {
{{className}} mstate = ({{className}}) values.elementAt(i);
if (mstate.mValue == value) return mstate;
}
throw new RuntimeException("{{className}} not found [" + value + "]");
}
public String toString() {
return mStringValue;
}
}
\ No newline at end of file
/*
{{className}}.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package {{packageName}}
{{#imports}}
import {{import}}
{{/imports}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
public interface {{className}} {
{{#methods}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
{{#deprecated}}@deprecated
{{/deprecated}}public {{return}} {{name}}({{params}}){{#exception}} throws CoreException{{/exception}};
{{/methods}}
}
\ No newline at end of file
/*
{{classNameStub}}.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package {{packageName}}
{{#imports}}
import {{import}}
{{/imports}}
public class {{classNameStub}} implements {{className}} {
{{#methods}}
@Override
public {{return}} {{name}}({{params}}){{#exception}} throws CoreException{{/exception}} {
// Auto-generated method stub
}
{{/methods}}
}
\ No newline at end of file
/*
linphone_jni.cc
Copyright (C) 2017 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <jni.h>
#include <cpu-features.h>
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) {
#ifdef __ANDROID__
ms_set_jvm(ajvm);
#endif /* __ANDROID__ */
jvm=ajvm;
return JNI_VERSION_1_2;
}
static const char* GetStringUTFChars(JNIEnv* env, jstring string) {
const char *cstring = string ? env->GetStringUTFChars(string, NULL) : NULL;
return cstring;
}
static void ReleaseStringUTFChars(JNIEnv* env, jstring string, const char *cstring) {
if (string) env->ReleaseStringUTFChars(string, cstring);
}
\ No newline at end of file
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