summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfalkTX <falktx@falktx.com>2019-07-12 11:25:20 +0200
committerfalkTX <falktx@falktx.com>2019-07-12 11:25:20 +0200
commitcde65ceac43832397040dcaaff5f1f1d5b297637 (patch)
tree05d12eceb925bcf0afef9dc42ba13eee1ee66a8f
parent33b92082465b31d839ecb78eecc5df9ec12cbcf1 (diff)
Add a int/uint/int2/uint2 variants of d_safe_assert
Signed-off-by: falkTX <falktx@falktx.com>
-rw-r--r--distrho/DistrhoUtils.hpp40
-rw-r--r--distrho/src/DistrhoDefines.h16
2 files changed, 56 insertions, 0 deletions
diff --git a/distrho/DistrhoUtils.hpp b/distrho/DistrhoUtils.hpp
index ee2cb571..4cf8ac73 100644
--- a/distrho/DistrhoUtils.hpp
+++ b/distrho/DistrhoUtils.hpp
@@ -157,6 +157,46 @@ void d_safe_assert(const char* const assertion, const char* const file, const in
}
/*
+ * Print a safe assertion error message, with 1 extra signed integer value.
+ */
+static inline
+void d_safe_assert_int(const char* const assertion, const char* const file,
+ const int line, const int value) noexcept
+{
+ d_stderr2("assertion failure: \"%s\" in file %s, line %i, value %i", assertion, file, line, value);
+}
+
+/*
+ * Print a safe assertion error message, with 1 extra unsigned integer value.
+ */
+static inline
+void d_safe_assert_uint(const char* const assertion, const char* const file,
+ const int line, const uint value) noexcept
+{
+ d_stderr2("assertion failure: \"%s\" in file %s, line %i, value %u", assertion, file, line, value);
+}
+
+/*
+ * Print a safe assertion error message, with 2 extra signed integer values.
+ */
+static inline
+void d_safe_assert_int2(const char* const assertion, const char* const file,
+ const int line, const int v1, const int v2) noexcept
+{
+ d_stderr2("assertion failure: \"%s\" in file %s, line %i, v1 %i, v2 %i", assertion, file, line, v1, v2);
+}
+
+/*
+ * Print a safe assertion error message, with 2 extra unsigned integer values.
+ */
+static inline
+void d_safe_assert_uint2(const char* const assertion, const char* const file,
+ const int line, const uint v1, const uint v2) noexcept
+{
+ d_stderr2("assertion failure: \"%s\" in file %s, line %i, v1 %u, v2 %u", assertion, file, line, v1, v2);
+}
+
+/*
* Print a safe exception error message.
*/
static inline
diff --git a/distrho/src/DistrhoDefines.h b/distrho/src/DistrhoDefines.h
index f16e44d5..4db7033b 100644
--- a/distrho/src/DistrhoDefines.h
+++ b/distrho/src/DistrhoDefines.h
@@ -81,6 +81,22 @@
#define DISTRHO_SAFE_ASSERT_CONTINUE(cond) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); continue; }
#define DISTRHO_SAFE_ASSERT_RETURN(cond, ret) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); return ret; }
+#define DISTRHO_SAFE_ASSERT_INT_BREAK(cond, value) if (! (cond)) { d_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value); break; }
+#define DISTRHO_SAFE_ASSERT_INT_CONTINUE(cond, value) if (! (cond)) { d_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value)); continue; }
+#define DISTRHO_SAFE_ASSERT_INT_RETURN(cond, value, ret) if (! (cond)) { d_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value)); return ret; }
+
+#define DISTRHO_SAFE_ASSERT_INT2_BREAK(cond, v1, v2) if (! (cond)) { d_safe_assert_int2(#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2)); break; }
+#define DISTRHO_SAFE_ASSERT_INT2_CONTINUE(cond, v1, v2) if (! (cond)) { d_safe_assert_int2(#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2)); continue; }
+#define DISTRHO_SAFE_ASSERT_INT2_RETURN(cond, v1, v2, ret) if (! (cond)) { d_safe_assert_int2(#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2)); return ret; }
+
+#define DISTRHO_SAFE_ASSERT_UINT_BREAK(cond, value) if (! (cond)) { d_safe_assert_uint(#cond, __FILE__, __LINE__, static_cast<uint>(value); break; }
+#define DISTRHO_SAFE_ASSERT_UINT_CONTINUE(cond, value) if (! (cond)) { d_safe_assert_uint(#cond, __FILE__, __LINE__, static_cast<uint>(value)); continue; }
+#define DISTRHO_SAFE_ASSERT_UINT_RETURN(cond, value, ret) if (! (cond)) { d_safe_assert_uint(#cond, __FILE__, __LINE__, static_cast<uint>(value)); return ret; }
+
+#define DISTRHO_SAFE_ASSERT_UINT2_BREAK(cond, v1, v2) if (! (cond)) { d_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); break; }
+#define DISTRHO_SAFE_ASSERT_UINT2_CONTINUE(cond, v1, v2) if (! (cond)) { d_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); continue; }
+#define DISTRHO_SAFE_ASSERT_UINT2_RETURN(cond, v1, v2, ret) if (! (cond)) { d_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); return ret; }
+
/* Define DISTRHO_SAFE_EXCEPTION */
#define DISTRHO_SAFE_EXCEPTION(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); }
#define DISTRHO_SAFE_EXCEPTION_BREAK(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); break; }