Fixed some issues in generated Java code

This commit is contained in:
Sylvain Berfini 2017-10-12 14:07:23 +02:00
parent d63af8a799
commit 5c52c4db70
3 changed files with 47 additions and 1 deletions

View file

@ -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);
}
}

View file

@ -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()

View file

@ -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}}