diff options
| author | 2021-06-02 00:34:48 -0400 | |
|---|---|---|
| committer | 2021-06-02 00:34:48 -0400 | |
| commit | 377cd301b30aaee015d6981387284ab5cbd7cc3e (patch) | |
| tree | 88f1d045919187bd67dce2d7bbcaf301046bae6b /src | |
| parent | Merge pull request #6397 from Morph1984/fs_util (diff) | |
| parent | common_funcs: Move R_ macros to result.h (diff) | |
| download | yuzu-377cd301b30aaee015d6981387284ab5cbd7cc3e.tar.gz yuzu-377cd301b30aaee015d6981387284ab5cbd7cc3e.tar.xz yuzu-377cd301b30aaee015d6981387284ab5cbd7cc3e.zip | |
Merge pull request #6395 from lioncash/result-move
common_funcs: Move R_ macros to result.h
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/common_funcs.h | 25 | ||||
| -rw-r--r-- | src/core/hle/result.h | 25 |
2 files changed, 25 insertions, 25 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 17d1ee86b..53bd7da60 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h | |||
| @@ -97,17 +97,6 @@ __declspec(dllimport) void __stdcall DebugBreak(void); | |||
| 97 | return static_cast<T>(key) == 0; \ | 97 | return static_cast<T>(key) == 0; \ |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | /// Evaluates a boolean expression, and returns a result unless that expression is true. | ||
| 101 | #define R_UNLESS(expr, res) \ | ||
| 102 | { \ | ||
| 103 | if (!(expr)) { \ | ||
| 104 | if (res.IsError()) { \ | ||
| 105 | LOG_ERROR(Kernel, "Failed with result: {}", res.raw); \ | ||
| 106 | } \ | ||
| 107 | return res; \ | ||
| 108 | } \ | ||
| 109 | } | ||
| 110 | |||
| 111 | #define YUZU_NON_COPYABLE(cls) \ | 100 | #define YUZU_NON_COPYABLE(cls) \ |
| 112 | cls(const cls&) = delete; \ | 101 | cls(const cls&) = delete; \ |
| 113 | cls& operator=(const cls&) = delete | 102 | cls& operator=(const cls&) = delete |
| @@ -116,20 +105,6 @@ __declspec(dllimport) void __stdcall DebugBreak(void); | |||
| 116 | cls(cls&&) = delete; \ | 105 | cls(cls&&) = delete; \ |
| 117 | cls& operator=(cls&&) = delete | 106 | cls& operator=(cls&&) = delete |
| 118 | 107 | ||
| 119 | #define R_SUCCEEDED(res) (res.IsSuccess()) | ||
| 120 | |||
| 121 | /// Evaluates an expression that returns a result, and returns the result if it would fail. | ||
| 122 | #define R_TRY(res_expr) \ | ||
| 123 | { \ | ||
| 124 | const auto _tmp_r_try_rc = (res_expr); \ | ||
| 125 | if (_tmp_r_try_rc.IsError()) { \ | ||
| 126 | return _tmp_r_try_rc; \ | ||
| 127 | } \ | ||
| 128 | } | ||
| 129 | |||
| 130 | /// Evaluates a boolean expression, and succeeds if that expression is true. | ||
| 131 | #define R_SUCCEED_IF(expr) R_UNLESS(!(expr), RESULT_SUCCESS) | ||
| 132 | |||
| 133 | namespace Common { | 108 | namespace Common { |
| 134 | 109 | ||
| 135 | [[nodiscard]] constexpr u32 MakeMagic(char a, char b, char c, char d) { | 110 | [[nodiscard]] constexpr u32 MakeMagic(char a, char b, char c, char d) { |
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 43968386f..df3283fe3 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h | |||
| @@ -358,3 +358,28 @@ ResultVal<std::remove_reference_t<Arg>> MakeResult(Arg&& arg) { | |||
| 358 | return CONCAT2(check_result_L, __LINE__); \ | 358 | return CONCAT2(check_result_L, __LINE__); \ |
| 359 | } \ | 359 | } \ |
| 360 | } while (false) | 360 | } while (false) |
| 361 | |||
| 362 | #define R_SUCCEEDED(res) (res.IsSuccess()) | ||
| 363 | |||
| 364 | /// Evaluates a boolean expression, and succeeds if that expression is true. | ||
| 365 | #define R_SUCCEED_IF(expr) R_UNLESS(!(expr), RESULT_SUCCESS) | ||
| 366 | |||
| 367 | /// Evaluates a boolean expression, and returns a result unless that expression is true. | ||
| 368 | #define R_UNLESS(expr, res) \ | ||
| 369 | { \ | ||
| 370 | if (!(expr)) { \ | ||
| 371 | if (res.IsError()) { \ | ||
| 372 | LOG_ERROR(Kernel, "Failed with result: {}", res.raw); \ | ||
| 373 | } \ | ||
| 374 | return res; \ | ||
| 375 | } \ | ||
| 376 | } | ||
| 377 | |||
| 378 | /// Evaluates an expression that returns a result, and returns the result if it would fail. | ||
| 379 | #define R_TRY(res_expr) \ | ||
| 380 | { \ | ||
| 381 | const auto _tmp_r_try_rc = (res_expr); \ | ||
| 382 | if (_tmp_r_try_rc.IsError()) { \ | ||
| 383 | return _tmp_r_try_rc; \ | ||
| 384 | } \ | ||
| 385 | } | ||