[arrayfire] 68/84: Change AF_THROW_MSG to AF_THROW_ERR - Does not check for AF_SUCCESS

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Jan 4 23:22:27 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository arrayfire.

commit 9604fccba36b24822d4fdb2ace67cd267a7f9cb3
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Tue Dec 29 15:48:10 2015 -0500

    Change AF_THROW_MSG to AF_THROW_ERR - Does not check for AF_SUCCESS
    
    * Also removed the THROW macro
---
 src/api/cpp/array.cpp | 10 +++++-----
 src/api/cpp/error.hpp |  7 ++-----
 src/api/cpp/gfor.cpp  |  2 +-
 src/api/cpp/seq.cpp   |  4 ++--
 src/api/cpp/where.cpp |  2 +-
 5 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/api/cpp/array.cpp b/src/api/cpp/array.cpp
index ef9a06a..f7931cf 100644
--- a/src/api/cpp/array.cpp
+++ b/src/api/cpp/array.cpp
@@ -32,7 +32,7 @@ namespace af
     static af_array gforReorder(const af_array in, unsigned dim)
     {
         // This is here to stop gcc from complaining
-        if (dim > 3) AF_THROW_MSG("GFor: Dimension is invalid", AF_ERR_SIZE);
+        if (dim > 3) AF_THROW_ERR("GFor: Dimension is invalid", AF_ERR_SIZE);
         unsigned order[AF_MAX_DIMS] = {0, 1, 2, dim};
         order[dim] = 3;
         af_array out;
@@ -67,7 +67,7 @@ namespace af
             }
             return odims;
         } catch(std::logic_error &err) {
-            AF_THROW_MSG(err.what(), AF_ERR_SIZE);
+            AF_THROW_ERR(err.what(), AF_ERR_SIZE);
         }
     }
 
@@ -138,7 +138,7 @@ namespace af
         switch (src) {
         case afHost:   AF_THROW(af_create_array(arr, (const void * const)ptr, AF_MAX_DIMS, my_dims, ty)); break;
         case afDevice: AF_THROW(af_device_array(arr, (const void *      )ptr, AF_MAX_DIMS, my_dims, ty)); break;
-        default: AF_THROW_MSG("Can not create array from the requested source pointer",
+        default: AF_THROW_ERR("Can not create array from the requested source pointer",
                               AF_ERR_ARG);
         }
     }
@@ -347,7 +347,7 @@ namespace af
                 case 2: return gen_indexing(*this, z, s0, z, z);
                 case 3: return gen_indexing(*this, z, z, s0, z);
                 case 4: return gen_indexing(*this, z, z, z, s0);
-                default: AF_THROW_MSG("ndims for Array is invalid", AF_ERR_SIZE);
+                default: AF_THROW_ERR("ndims for Array is invalid", AF_ERR_SIZE);
             }
         }
         else {
@@ -968,7 +968,7 @@ af::dtype implicit_dtype(af::dtype scalar_type, af::dtype array_type)
     template<> AFAPI T *array::host() const                         \
     {                                                               \
         if (type() != (af::dtype)dtype_traits<T>::af_type) {        \
-            AF_THROW_MSG("Requested type doesn't match with array", \
+            AF_THROW_ERR("Requested type doesn't match with array", \
                          AF_ERR_TYPE);                              \
         }                                                           \
                                                                     \
diff --git a/src/api/cpp/error.hpp b/src/api/cpp/error.hpp
index cb5a573..157f819 100644
--- a/src/api/cpp/error.hpp
+++ b/src/api/cpp/error.hpp
@@ -16,9 +16,6 @@
         throw af::exception(__AF_FILENAME__, __LINE__, __err); \
     } while(0)
 
-#define AF_THROW_MSG(__msg, __err) do {                         \
-        if (__err == AF_SUCCESS) break;                         \
+#define AF_THROW_ERR(__msg, __err) do {                         \
         throw af::exception(__msg, __AF_FILENAME__, __LINE__, __err);  \
-    } while(0);
-
-#define THROW(__err) throw af::exception(__AF_FILENAME__, __LINE__, __err)
+    } while(0)
diff --git a/src/api/cpp/gfor.cpp b/src/api/cpp/gfor.cpp
index 3918b39..b442164 100644
--- a/src/api/cpp/gfor.cpp
+++ b/src/api/cpp/gfor.cpp
@@ -32,7 +32,7 @@ namespace af
 
     array batchFunc(const array &lhs, const array &rhs, batchFunc_t func)
     {
-        if (gforGet()) AF_THROW_MSG("batchFunc can not be used inside GFOR",
+        if (gforGet()) AF_THROW_ERR("batchFunc can not be used inside GFOR",
                                     AF_ERR_ARG);
         gforSet(true);
         array res = func(lhs, rhs);
diff --git a/src/api/cpp/seq.cpp b/src/api/cpp/seq.cpp
index 0ef9326..dff2e39 100644
--- a/src/api/cpp/seq.cpp
+++ b/src/api/cpp/seq.cpp
@@ -67,10 +67,10 @@ seq::seq(double begin, double end, double step): m_gfor(false)
 {
     if (step == 0) {
         if (begin != end)   // Span
-            AF_THROW_MSG("Invalid step size", AF_ERR_ARG);
+            AF_THROW_ERR("Invalid step size", AF_ERR_ARG);
     }
     if (end >= 0 && begin >= 0 && signbit(end-begin) != signbit(step))
-        AF_THROW_MSG("Sequence is invalid", AF_ERR_ARG);
+        AF_THROW_ERR("Sequence is invalid", AF_ERR_ARG);
         //AF_THROW("step must match direction of sequence");
     init(begin, end, step);
 }
diff --git a/src/api/cpp/where.cpp b/src/api/cpp/where.cpp
index aa16818..fd97059 100644
--- a/src/api/cpp/where.cpp
+++ b/src/api/cpp/where.cpp
@@ -17,7 +17,7 @@ namespace af
     array where(const array& in)
     {
         if (gforGet()) {
-            AF_THROW_MSG("WHERE can not be used inside GFOR", AF_ERR_RUNTIME);
+            AF_THROW_ERR("WHERE can not be used inside GFOR", AF_ERR_RUNTIME);
         }
 
         af_array out = 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list