summaryrefslogtreecommitdiffstats
path: root/src/core/hle/result.h
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-10-23 03:16:38 +0200
committerLiam <byteslice@airmail.cc>2023-11-10 18:01:35 +0100
commit2a255b2d61a445fb2b83cc8af7632e3d720e1292 (patch)
tree37f5c16ba52339d91e57c5b975639dc1eb60b9f7 /src/core/hle/result.h
parentMerge pull request #11981 from lucasreis1/patch (diff)
downloadyuzu-2a255b2d61a445fb2b83cc8af7632e3d720e1292.tar
yuzu-2a255b2d61a445fb2b83cc8af7632e3d720e1292.tar.gz
yuzu-2a255b2d61a445fb2b83cc8af7632e3d720e1292.tar.bz2
yuzu-2a255b2d61a445fb2b83cc8af7632e3d720e1292.tar.lz
yuzu-2a255b2d61a445fb2b83cc8af7632e3d720e1292.tar.xz
yuzu-2a255b2d61a445fb2b83cc8af7632e3d720e1292.tar.zst
yuzu-2a255b2d61a445fb2b83cc8af7632e3d720e1292.zip
Diffstat (limited to 'src/core/hle/result.h')
-rw-r--r--src/core/hle/result.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index dd0b27f47..749f51f69 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -407,3 +407,34 @@ constexpr inline Result __TmpCurrentResultReference = ResultSuccess;
/// Evaluates a boolean expression, and succeeds if that expression is true.
#define R_SUCCEED_IF(expr) R_UNLESS(!(expr), ResultSuccess)
+
+#define R_TRY_CATCH(res_expr) \
+ { \
+ const auto R_CURRENT_RESULT = (res_expr); \
+ if (R_FAILED(R_CURRENT_RESULT)) { \
+ if (false)
+
+#define R_END_TRY_CATCH \
+ else if (R_FAILED(R_CURRENT_RESULT)) { \
+ R_THROW(R_CURRENT_RESULT); \
+ } \
+ } \
+ }
+
+#define R_CATCH_ALL() \
+ } \
+ else if (R_FAILED(R_CURRENT_RESULT)) { \
+ if (true)
+
+#define R_CATCH(res_expr) \
+ } \
+ else if ((res_expr) == (R_CURRENT_RESULT)) { \
+ if (true)
+
+#define R_CONVERT(catch_type, convert_type) \
+ R_CATCH(catch_type) { R_THROW(static_cast<Result>(convert_type)); }
+
+#define R_CONVERT_ALL(convert_type) \
+ R_CATCH_ALL() { R_THROW(static_cast<Result>(convert_type)); }
+
+#define R_ASSERT(res_expr) ASSERT(R_SUCCEEDED(res_expr))