Mercurial > hg > octave-nkf
changeset 15820:00172e5c2302
Add autoconversion of Java numeric types (byte, short, integer, long, float) to Octave double.
Operation is only for scalar return results and matches Matlab behavior.
* libinterp/octave-value/ov-java.cc(box): Check for instance of superclass
java.lang.Number and convert to double value.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 19 Dec 2012 17:02:55 -0800 |
parents | 1e9a6285acc4 |
children | 72661fe4b9e5 |
files | libinterp/octave-value/ov-java.cc |
diffstat | 1 files changed, 3 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-java.cc +++ b/libinterp/octave-value/ov-java.cc @@ -923,20 +923,11 @@ if (! jobj) retval = Matrix (); + // Convert a scalar of any numeric class (byte, short, integer, long, float, + // double) to a double value. Matlab does the same thing. if (retval.is_undefined ()) { - cls = jni_env->FindClass ("java/lang/Integer"); - - if (jni_env->IsInstanceOf (jobj, cls)) - { - jmethodID m = jni_env->GetMethodID (cls, "intValue", "()I"); - retval = jni_env->CallIntMethod (jobj, m); - } - } - - if (retval.is_undefined ()) - { - cls = jni_env->FindClass ("java/lang/Double"); + cls = jni_env->FindClass ("java/lang/Number"); if (jni_env->IsInstanceOf (jobj, cls)) { @@ -952,7 +943,6 @@ if (jni_env->IsInstanceOf (jobj, cls)) { jmethodID m = jni_env->GetMethodID (cls, "booleanValue", "()Z"); - // MH retval = jni_env->CallBooleanMethod (jobj, m); retval = (jni_env->CallBooleanMethod (jobj, m) ? true : false); } }