# HG changeset patch # User Carnë Draug # Date 1429547008 -3600 # Node ID 41064c150724e7c7dbda95c8f6a384ccc9e1bfb8 # Parent 2db2db2df55bff44e205772d033f9e8397acf2b1 Return bools instead of ints in oc-java box and unbox internal functions. * libinterp/octave-value/ov-java.cc (unbox): this functions return an int with value of 0 or 1 only but are always used as booleans. diff -r 2db2db2df55b -r 41064c150724 libinterp/octave-value/ov-java.cc --- a/libinterp/octave-value/ov-java.cc Mon Apr 20 15:01:27 2015 +0100 +++ b/libinterp/octave-value/ov-java.cc Mon Apr 20 17:23:28 2015 +0100 @@ -1261,11 +1261,11 @@ return retval; } -int +bool unbox (JNIEnv* jni_env, const octave_value& val, jobject_ref& jobj, jclass_ref& jcls) { - int found = 1; + bool found = true; if (val.is_java ()) { @@ -1393,7 +1393,7 @@ } else { - found = 0; + found = false; error ("cannot convert matrix of type '%s'", val.class_name ().c_str ()); } } @@ -1425,11 +1425,11 @@ return found; } -int +bool unbox (JNIEnv* jni_env, const octave_value_list& args, jobjectArray_ref& jobjs, jobjectArray_ref& jclss) { - int found = 1; + bool found = true; jclass_ref ocls (jni_env, jni_env->FindClass ("java/lang/Object")); jclass_ref ccls (jni_env, jni_env->FindClass ("java/lang/Class")); @@ -1445,11 +1445,9 @@ jobject_ref jobj (jni_env); jclass_ref jcls (jni_env); - if (! unbox (jni_env, args(i), jobj, jcls)) - { - found = 0; - break; - } + found = unbox (jni_env, args(i), jobj, jcls); + if (! found) + break; jni_env->SetObjectArrayElement (jobjs, i, jobj); jni_env->SetObjectArrayElement (jclss, i, jcls); @@ -1537,18 +1535,12 @@ varargin(i) = box (env, env->GetObjectArrayElement (argin, i), 0); varargout = feval (fname, varargin, nargout); - - if (! error_state) - { - jobjectArray_ref out_objs (env, argout), out_clss (env); + if (error_state) + return false; - out_objs.detach (); - - if (unbox (env, varargout, out_objs, out_clss)) - return true; - } - - return false; + jobjectArray_ref out_objs (env, argout), out_clss (env); + out_objs.detach (); + return unbox (env, varargout, out_objs, out_clss); } JNIEXPORT void JNICALL diff -r 2db2db2df55b -r 41064c150724 libinterp/octave-value/ov-java.h --- a/libinterp/octave-value/ov-java.h Mon Apr 20 15:01:27 2015 +0100 +++ b/libinterp/octave-value/ov-java.h Mon Apr 20 17:23:28 2015 +0100 @@ -95,11 +95,11 @@ extern OCTINTERP_API octave_value box_more (JNIEnv* jni_env, jobject jobj, jclass jcls = 0); -extern OCTINTERP_API int +extern OCTINTERP_API bool unbox (JNIEnv* jni_env, const octave_value& val, jobject_ref& jobj, jclass_ref& jcls); -extern OCTINTERP_API int +extern OCTINTERP_API bool unbox (JNIEnv* jni_env, const octave_value_list& args, jobjectArray_ref& jobjs, jobjectArray_ref& jclss);