mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-07-01 07:12:14 +02:00
results: Add R_ASSERT helper.
This commit is contained in:
parent
3274848b56
commit
7c9df9cfd8
@ -20,6 +20,21 @@ extern "C" {
|
|||||||
} \
|
} \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/// Evaluates an expression that returns a result, and fatals the result if it would fail.
|
||||||
|
#ifdef RESULT_ABORT_ON_ASSERT
|
||||||
|
#define R_ASSERT_IMPL(res) std::abort()
|
||||||
|
#else
|
||||||
|
#define R_ASSERT_IMPL(res) fatalSimple(res)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define R_ASSERT(res_expr) \
|
||||||
|
({ \
|
||||||
|
const Result _tmp_r_assert_rc = res_expr; \
|
||||||
|
if (R_FAILED(_tmp_r_assert_rc)) { \
|
||||||
|
R_ASSERT_IMPL(_tmp_r_assert_rc); \
|
||||||
|
} \
|
||||||
|
})
|
||||||
|
|
||||||
/// Helpers for pattern-matching on a result expression, if the result would fail.
|
/// Helpers for pattern-matching on a result expression, if the result would fail.
|
||||||
#define R_TRY_CATCH(res_expr) \
|
#define R_TRY_CATCH(res_expr) \
|
||||||
({ \
|
({ \
|
||||||
@ -47,6 +62,11 @@ extern "C" {
|
|||||||
if (false) { } \
|
if (false) { } \
|
||||||
else
|
else
|
||||||
|
|
||||||
|
#define R_CATCH_ALL() \
|
||||||
|
} else if (R_FAILED(_tmp_r_try_catch_rc)) { \
|
||||||
|
if (false) { } \
|
||||||
|
else
|
||||||
|
|
||||||
#define R_END_TRY_CATCH \
|
#define R_END_TRY_CATCH \
|
||||||
else if (R_FAILED(_tmp_r_try_catch_rc)) { \
|
else if (R_FAILED(_tmp_r_try_catch_rc)) { \
|
||||||
return _tmp_r_try_catch_rc; \
|
return _tmp_r_try_catch_rc; \
|
||||||
|
Loading…
Reference in New Issue
Block a user