diff options
| author | 2017-06-05 23:13:58 -0700 | |
|---|---|---|
| committer | 2017-06-06 00:51:57 -0700 | |
| commit | 7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332 (patch) | |
| tree | 3be2c22e9e1bc5199072734be2af03522d8204cb /src | |
| parent | HLE: Move SessionRequestHandler from Service:: to Kernel:: (diff) | |
| download | yuzu-7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332.tar.gz yuzu-7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332.tar.xz yuzu-7e5dd46cf4c7be421b6a86a661f6dd9cd1ef4332.zip | |
ResultVal: Add more convenience utils for creating and cascading results
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/result.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index c49650f7d..5f2cdbb96 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h | |||
| @@ -416,6 +416,16 @@ ResultVal<T> MakeResult(Args&&... args) { | |||
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | /** | 418 | /** |
| 419 | * Deducible overload of MakeResult, allowing the template parameter to be ommited if you're just | ||
| 420 | * copy or move constructing. | ||
| 421 | */ | ||
| 422 | template <typename Arg> | ||
| 423 | ResultVal<std::remove_reference_t<Arg>> MakeResult(Arg&& arg) { | ||
| 424 | return ResultVal<std::remove_reference_t<Arg>>::WithCode(RESULT_SUCCESS, | ||
| 425 | std::forward<Arg>(arg)); | ||
| 426 | } | ||
| 427 | |||
| 428 | /** | ||
| 419 | * Check for the success of `source` (which must evaluate to a ResultVal). If it succeeds, unwraps | 429 | * Check for the success of `source` (which must evaluate to a ResultVal). If it succeeds, unwraps |
| 420 | * the contained value and assigns it to `target`, which can be either an l-value expression or a | 430 | * the contained value and assigns it to `target`, which can be either an l-value expression or a |
| 421 | * variable declaration. If it fails the return code is returned from the current function. Thus it | 431 | * variable declaration. If it fails the return code is returned from the current function. Thus it |
| @@ -426,3 +436,12 @@ ResultVal<T> MakeResult(Args&&... args) { | |||
| 426 | if (CONCAT2(check_result_L, __LINE__).Failed()) \ | 436 | if (CONCAT2(check_result_L, __LINE__).Failed()) \ |
| 427 | return CONCAT2(check_result_L, __LINE__).Code(); \ | 437 | return CONCAT2(check_result_L, __LINE__).Code(); \ |
| 428 | target = std::move(*CONCAT2(check_result_L, __LINE__)) | 438 | target = std::move(*CONCAT2(check_result_L, __LINE__)) |
| 439 | |||
| 440 | /** | ||
| 441 | * Analogous to CASCADE_RESULT, but for a bare ResultCode. The code will be propagated if | ||
| 442 | * non-success, or discarded otherwise. | ||
| 443 | */ | ||
| 444 | #define CASCADE_CODE(source) \ | ||
| 445 | auto CONCAT2(check_result_L, __LINE__) = source; \ | ||
| 446 | if (CONCAT2(check_result_L, __LINE__).IsError()) \ | ||
| 447 | return CONCAT2(check_result_L, __LINE__); | ||