Commit 82f3d21b authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Added an option on Java wrapper for exceptions, default to false temporarily

parent a0b59e43
......@@ -68,7 +68,8 @@ ENUMS_LIST = {
##########################################################################
class JavaTranslator(object):
def __init__(self, packageName):
def __init__(self, packageName, exceptions):
self.exceptions = exceptions
package_dirs = packageName.split('.')
self.jni_package = ''
self.jni_path = ''
......@@ -79,6 +80,8 @@ class JavaTranslator(object):
self.docTranslator = metadoc.SandcastleJavaTranslator()
def throws_exception(self, _type):
if not self.exceptions:
return False
if type(_type) is AbsApi.BaseType:
if _type.name == 'status':
return True
......@@ -716,10 +719,11 @@ class Jni(object):
##########################################################################
class GenWrapper(object):
def __init__(self, srcdir, javadir, package, xmldir):
def __init__(self, srcdir, javadir, package, xmldir, exceptions):
self.srcdir = srcdir
self.javadir = javadir
self.package = package
self.exceptions = exceptions
project = CApi.Project()
project.initFromDir(xmldir)
......@@ -734,7 +738,7 @@ class GenWrapper(object):
'linphone_call_zoom_video',\
'linphone_config_get_range']
self.parser.parse_all()
self.translator = JavaTranslator(package)
self.translator = JavaTranslator(package, exceptions)
self.renderer = pystache.Renderer()
self.jni = Jni(package)
......@@ -820,6 +824,7 @@ def main():
argparser.add_argument('-o --output', type=str, help='the directory where to generate the source files', dest='outputdir', default='.')
argparser.add_argument('-p --package', type=str, help='the package name for the wrapper', dest='package', default='org.linphone.core')
argparser.add_argument('-n --name', type=str, help='the name of the genarated source file', dest='name', default='linphone_jni.cc')
argparser.add_argument('-e --exceptions', type=bool, help='enable the wrapping of LinphoneStatus into CoreException', dest='exceptions', default=False)
args = argparser.parse_args()
srcdir = args.outputdir + '/src'
......@@ -842,7 +847,7 @@ def main():
print("Cannot create '{0}' dircetory: {1}".format(javadir, e.strerror))
sys.exit(1)
genwrapper = GenWrapper(srcdir, javadir, args.package, args.xmldir)
genwrapper = GenWrapper(srcdir, javadir, args.package, args.xmldir, args.exceptions)
genwrapper.render_all()
if __name__ == '__main__':
......
......@@ -63,13 +63,13 @@ public {{#isLinphoneFactory}}abstract class{{/isLinphoneFactory}}{{#isNotLinphon
mValue = value;
}
static public {{className}} fromInt(int value) throws CoreException {
static public {{className}} fromInt(int value) throws RuntimeException {
switch(value) {
{{#values}}
case {{value}}: return {{name}};
{{/values}}
default:
throw new CoreException("Unhandled enum value " + value + " for {{className}}");
throw new RuntimeException("Unhandled enum value " + value + " for {{className}}");
}
}
......
......@@ -48,13 +48,13 @@ public enum {{className}} {
mValue = value;
}
static public {{className}} fromInt(int value) throws CoreException {
static public {{className}} fromInt(int value) throws RuntimeException {
switch(value) {
{{#values}}
case {{value}}: return {{name}};
{{/values}}
default:
throw new CoreException("Unhandled enum value " + value + " for {{className}}");
throw new RuntimeException("Unhandled enum value " + value + " for {{className}}");
}
}
......
......@@ -196,6 +196,8 @@ eval "$SED_START 's/getIncomingTimeout/getIncTimeout/g' $SED_END"
eval "$SED_START 's/setIncomingTimeout/setIncTimeout/g' $SED_END"
eval "$SED_START 's/migrateCallLogs()/migrateLogsFromRcToDb()/g' $SED_END"
eval "$SED_START 's/setRLSUri/setRlsUri/g' $SED_END"
eval "$SED_START 's/hasCrappyOpenGL(/hasCrappyOpenGl(/g' $SED_END"
eval "$SED_START 's/needsEchoCalibration(/isEchoCancellerCalibrationRequired(/g' $SED_END"
# Removed methods
eval "$SED_START 's/.isRegistered()/.getState() == RegistrationState.Ok/g' $SED_END"
......@@ -240,11 +242,7 @@ eval "$SED_START 's/zoomVideo(/zoom(/g' $SED_END"
#AccountCreator.updatePassword
#Android specifics not wrapped automatically
#Core.needsEchoCalibration()
#Core.hasCrappyOpenGL()
#Core.startEchoCalibration
#Core.startEchoTester
#Core.stopEchoTester
# For the payloads, get the list from the Core, call the method on the object directly and set it back if required
#Core.enablePayloadType()
......
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