From 8217840accab93dd99f57357c0b08b61426445a8 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 19 May 2021 00:32:15 +0300 Subject: [PATCH] Simplify error_code class Remove "not an error" detection trait. Use fixed CellNotAnError class. Use constructor overload to disable reporting it. --- rpcs3/Emu/Cell/ErrorCodes.h | 48 +++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/rpcs3/Emu/Cell/ErrorCodes.h b/rpcs3/Emu/Cell/ErrorCodes.h index 022ece2657..2928108417 100644 --- a/rpcs3/Emu/Cell/ErrorCodes.h +++ b/rpcs3/Emu/Cell/ErrorCodes.h @@ -14,32 +14,12 @@ public: // Implementation must be provided independently static s32 error_report(const fmt_type_info* sup, u64 arg, const fmt_type_info* sup2, u64 arg2); - // Helper type - enum class not_an_error : s32 - { - __not_an_error // SFINAE marker - }; - - // __not_an_error tester - template - struct is_error : std::integral_constant::value || std::is_integral::value> - { - }; - - template - struct is_error> : std::false_type - { - }; - // Common constructor template error_code(const ET& value) : value(static_cast(value)) { - if constexpr(is_error::value) - { - this->value = error_report(fmt::get_type_info>(), fmt_unveil::get(value), nullptr, 0); - } + this->value = error_report(fmt::get_type_info>(), fmt_unveil::get(value), nullptr, 0); } // Error constructor (2 args) @@ -55,11 +35,24 @@ public: } }; +enum CellNotAnError : s32 +{ + CELL_OK = 0, + CELL_CANCEL = 1, +}; + +// Constructor specialization that doesn't trigger reporting +template <> +constexpr FORCE_INLINE error_code::error_code(const CellNotAnError& value) + : value(value) +{ +} + // Helper function for error_code template -constexpr FORCE_INLINE error_code::not_an_error not_an_error(const T& value) +constexpr FORCE_INLINE CellNotAnError not_an_error(const T& value) { - return static_cast(static_cast(value)); + return static_cast(static_cast(value)); } template @@ -79,15 +72,6 @@ struct ppu_gpr_cast_impl } }; - -enum CellNotAnError : s32 -{ - CELL_OK = 0, - CELL_CANCEL = 1, - - __not_an_error -}; - enum CellError : u32 { CELL_EAGAIN = 0x80010001, // The resource is temporarily unavailable