From 5c52c4db7070d5b0c7234033229fb5ca38fc2a6a Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 12 Oct 2017 14:07:23 +0200 Subject: [PATCH] Fixed some issues in generated Java code --- wrappers/java/classes/CoreException.java | 39 ++++++++++++++++++++++++ wrappers/java/genwrapper.py | 7 +++++ wrappers/java/java_class.mustache | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 wrappers/java/classes/CoreException.java diff --git a/wrappers/java/classes/CoreException.java b/wrappers/java/classes/CoreException.java new file mode 100644 index 000000000..3172687a1 --- /dev/null +++ b/wrappers/java/classes/CoreException.java @@ -0,0 +1,39 @@ +/* +CoreException.java +Copyright (C) 2010-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. +*/ + +package org.linphone.core; + +@SuppressWarnings("serial") +public class CoreException extends Exception { + + public CoreException() { + } + + public CoreException(String detailMessage) { + super(detailMessage); + } + + public CoreException(Throwable e) { + super(e); + } + + public CoreException(String detailMessage, Throwable e) { + super(detailMessage,e); + } +} diff --git a/wrappers/java/genwrapper.py b/wrappers/java/genwrapper.py index 749c4889e..256e17ef0 100644 --- a/wrappers/java/genwrapper.py +++ b/wrappers/java/genwrapper.py @@ -310,6 +310,7 @@ class JavaTranslator(object): for arg in _method.args: if arg is not _method.args[0]: methodDict['params'] += ', ' + methodDict['static_native_params'] += ', ' methodDict['native_params'] += ', ' methodDict['native_params_impl'] += ', ' @@ -799,6 +800,7 @@ class GenWrapper(object): ########################################################################## def main(): + import shutil argparser = argparse.ArgumentParser(description='Generate source files for the Java 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='.') @@ -829,5 +831,10 @@ def main(): genwrapper = GenWrapper(srcdir, javadir, args.package, args.xmldir) genwrapper.render_all() + for f in os.listdir('./classes'): + src = os.path.join('./classes', f) + tgt = os.path.join(javadir, f) + shutil.copy(src, tgt) + if __name__ == '__main__': main() diff --git a/wrappers/java/java_class.mustache b/wrappers/java/java_class.mustache index 873e3992a..77778af8d 100644 --- a/wrappers/java/java_class.mustache +++ b/wrappers/java/java_class.mustache @@ -145,7 +145,7 @@ class {{classImplName}} implements {{className}} { private native {{return_native}} {{name}}({{native_params}}); public {{return}} {{name}}({{params}}) {{#exception}}throws CoreException{{/exception}}{{#enumCast}}throws CoreException{{/enumCast}} { {{#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}} + if (exceptionResult != 0) throw new CoreException("{{name}} returned value " + exceptionResult);{{/exception}} } {{/methods}}