[PPL-devel] [GIT] ppl/ppl(master): Fixed result check for ThrowNew.
Abramo Bagnara
abramo.bagnara at gmail.com
Wed May 6 19:52:07 CEST 2009
Module: ppl/ppl
Branch: master
Commit: 9381e735bd8858563a577503cdccea25041d96d2
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=9381e735bd8858563a577503cdccea25041d96d2
Author: Abramo Bagnara <abramo.bagnara at gmail.com>
Date: Wed May 6 19:54:16 2009 +0200
Fixed result check for ThrowNew.
---
interfaces/Java/jni/ppl_java_common.cc | 16 ++++++++--------
interfaces/Java/jni/ppl_java_common.defs.hh | 20 ++++++++++----------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/interfaces/Java/jni/ppl_java_common.cc b/interfaces/Java/jni/ppl_java_common.cc
index 1e45bb0..bea6bc7 100644
--- a/interfaces/Java/jni/ppl_java_common.cc
+++ b/interfaces/Java/jni/ppl_java_common.cc
@@ -190,7 +190,7 @@ handle_exception(JNIEnv* env, const std::overflow_error& e) {
= env->FindClass("parma_polyhedra_library/Overflow_Error_Exception");
CHECK_RESULT_ASSERT(env, newExcCls);
jint ret = env->ThrowNew(newExcCls, e.what());
- CHECK_RESULT_ABORT(env, ret);
+ CHECK_RESULT_ABORT(env, ret == 0);
}
void
@@ -199,7 +199,7 @@ handle_exception(JNIEnv* env, const std::invalid_argument& e) {
= env->FindClass("parma_polyhedra_library/Invalid_Argument_Exception");
CHECK_RESULT_ASSERT(env, newExcCls);
jint ret = env->ThrowNew(newExcCls, e.what());
- CHECK_RESULT_ABORT(env, ret);
+ CHECK_RESULT_ABORT(env, ret == 0);
}
void
@@ -208,7 +208,7 @@ handle_exception(JNIEnv* env, const std::logic_error& e) {
= env->FindClass("parma_polyhedra_library/Logic_Error_Exception");
CHECK_RESULT_ASSERT(env, newExcCls);
jint ret = env->ThrowNew(newExcCls, e.what());
- CHECK_RESULT_ABORT(env, ret);
+ CHECK_RESULT_ABORT(env, ret == 0);
}
void
@@ -217,7 +217,7 @@ handle_exception(JNIEnv* env, const std::length_error& e) {
= env->FindClass("parma_polyhedra_library/Length_Error_Exception");
CHECK_RESULT_ASSERT(env, newExcCls);
jint ret = env->ThrowNew(newExcCls, e.what());
- CHECK_RESULT_ABORT(env, ret);
+ CHECK_RESULT_ABORT(env, ret == 0);
}
void
@@ -226,7 +226,7 @@ handle_exception(JNIEnv* env, const std::domain_error& e) {
= env->FindClass("parma_polyhedra_library/Domain_Error_Exception");
CHECK_RESULT_ASSERT(env, newExcCls);
jint ret = env->ThrowNew(newExcCls, e.what());
- CHECK_RESULT_ABORT(env, ret);
+ CHECK_RESULT_ABORT(env, ret == 0);
}
void
@@ -235,7 +235,7 @@ handle_exception(JNIEnv* env, const std::bad_alloc&) {
= env->FindClass("java/lang/RuntimeException");
CHECK_RESULT_ASSERT(env, newExcCls);
jint ret = env->ThrowNew(newExcCls, "Out of memory");
- CHECK_RESULT_ABORT(env, ret);
+ CHECK_RESULT_ABORT(env, ret == 0);
}
void
@@ -243,7 +243,7 @@ handle_exception(JNIEnv* env, const std::exception& e) {
jclass newExcCls = env->FindClass("java/lang/RuntimeException");
CHECK_RESULT_ASSERT(env, newExcCls);
jint ret = env->ThrowNew(newExcCls, e.what());
- CHECK_RESULT_ABORT(env, ret);
+ CHECK_RESULT_ABORT(env, ret == 0);
}
void
@@ -251,7 +251,7 @@ handle_exception(JNIEnv* env) {
jclass newExcCls = env->FindClass("java/lang/RuntimeException");
CHECK_RESULT_ASSERT(env, newExcCls);
jint ret = env->ThrowNew(newExcCls, "PPL bug: unknown exception raised");
- CHECK_RESULT_ABORT(env, ret);
+ CHECK_RESULT_ABORT(env, ret == 0);
}
jobject
diff --git a/interfaces/Java/jni/ppl_java_common.defs.hh b/interfaces/Java/jni/ppl_java_common.defs.hh
index 1d66c20..72f2d1c 100644
--- a/interfaces/Java/jni/ppl_java_common.defs.hh
+++ b/interfaces/Java/jni/ppl_java_common.defs.hh
@@ -75,26 +75,26 @@ site: http://www.cs.unipr.it/ppl/ . */
if (env->ExceptionOccurred()) \
return; \
} while (0)
-#define CHECK_RESULT_ABORT(env, result) \
+#define CHECK_RESULT_ABORT(env, cond) \
do { \
- if (!result) \
+ if (!(cond)) \
abort(); \
} while (0)
-#define CHECK_RESULT_ASSERT(env, result) \
- assert(result)
-#define CHECK_RESULT_THROW(env, result) \
+#define CHECK_RESULT_ASSERT(env, cond) \
+ assert(cond)
+#define CHECK_RESULT_THROW(env, cond) \
do { \
- if (!result) \
+ if (!(cond)) \
throw Java_ExceptionOccurred(); \
} while (0)
-#define CHECK_RESULT_RETURN(env, result, val) \
+#define CHECK_RESULT_RETURN(env, cond, val) \
do { \
- if (!result) \
+ if (!(cond)) \
return val; \
} while (0)
-#define CHECK_RESULT_RETURN_VOID(env, result) \
+#define CHECK_RESULT_RETURN_VOID(env, cond) \
do { \
- if (!result) \
+ if (!(cond)) \
return; \
} while (0)
More information about the PPL-devel
mailing list