summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/frontend/applets/error.cpp6
-rw-r--r--src/core/hle/result.h38
-rw-r--r--src/core/hle/service/am/applets/applet_error.cpp4
-rw-r--r--src/core/hle/service/audio/audren_u.cpp3
-rw-r--r--src/core/hle/service/caps/caps_a.cpp13
-rw-r--r--src/core/hle/service/fatal/fatal.cpp4
-rw-r--r--src/core/hle/service/nfc/nfc_interface.cpp2
-rw-r--r--src/core/reporter.cpp4
-rw-r--r--src/yuzu/applets/qt_error.cpp12
9 files changed, 57 insertions, 29 deletions
diff --git a/src/core/frontend/applets/error.cpp b/src/core/frontend/applets/error.cpp
index 2e6f7a3d9..53d4be2e5 100644
--- a/src/core/frontend/applets/error.cpp
+++ b/src/core/frontend/applets/error.cpp
@@ -12,7 +12,7 @@ void DefaultErrorApplet::Close() const {}
void DefaultErrorApplet::ShowError(Result error, FinishedCallback finished) const {
LOG_CRITICAL(Service_Fatal, "Application requested error display: {:04}-{:04} (raw={:08X})",
- error.module.Value(), error.description.Value(), error.raw);
+ error.GetModule(), error.GetDescription(), error.raw);
}
void DefaultErrorApplet::ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
@@ -20,7 +20,7 @@ void DefaultErrorApplet::ShowErrorWithTimestamp(Result error, std::chrono::secon
LOG_CRITICAL(
Service_Fatal,
"Application requested error display: {:04X}-{:04X} (raw={:08X}) with timestamp={:016X}",
- error.module.Value(), error.description.Value(), error.raw, time.count());
+ error.GetModule(), error.GetDescription(), error.raw, time.count());
}
void DefaultErrorApplet::ShowCustomErrorText(Result error, std::string main_text,
@@ -28,7 +28,7 @@ void DefaultErrorApplet::ShowCustomErrorText(Result error, std::string main_text
FinishedCallback finished) const {
LOG_CRITICAL(Service_Fatal,
"Application requested custom error with error_code={:04X}-{:04X} (raw={:08X})",
- error.module.Value(), error.description.Value(), error.raw);
+ error.GetModule(), error.GetDescription(), error.raw);
LOG_CRITICAL(Service_Fatal, " Main Text: {}", main_text);
LOG_CRITICAL(Service_Fatal, " Detail Text: {}", detail_text);
}
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index 749f51f69..316370266 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -189,14 +189,14 @@ enum class ErrorModule : u32 {
union Result {
u32 raw;
- BitField<0, 9, ErrorModule> module;
- BitField<9, 13, u32> description;
+ using Module = BitField<0, 9, ErrorModule>;
+ using Description = BitField<9, 13, u32>;
Result() = default;
constexpr explicit Result(u32 raw_) : raw(raw_) {}
constexpr Result(ErrorModule module_, u32 description_)
- : raw(module.FormatValue(module_) | description.FormatValue(description_)) {}
+ : raw(Module::FormatValue(module_) | Description::FormatValue(description_)) {}
[[nodiscard]] constexpr bool IsSuccess() const {
return raw == 0;
@@ -211,7 +211,15 @@ union Result {
}
[[nodiscard]] constexpr u32 GetInnerValue() const {
- return static_cast<u32>(module.Value()) | (description << module.bits);
+ return raw;
+ }
+
+ [[nodiscard]] constexpr ErrorModule GetModule() const {
+ return Module::ExtractValue(raw);
+ }
+
+ [[nodiscard]] constexpr u32 GetDescription() const {
+ return Description::ExtractValue(raw);
}
[[nodiscard]] constexpr bool Includes(Result result) const {
@@ -274,8 +282,9 @@ public:
}
[[nodiscard]] constexpr bool Includes(Result other) const {
- return code.module == other.module && code.description <= other.description &&
- other.description <= description_end;
+ return code.GetModule() == other.GetModule() &&
+ code.GetDescription() <= other.GetDescription() &&
+ other.GetDescription() <= description_end;
}
private:
@@ -330,6 +339,16 @@ constexpr bool EvaluateResultFailure(const Result& r) {
return R_FAILED(r);
}
+template <auto... R>
+constexpr bool EvaluateAnyResultIncludes(const Result& r) {
+ return ((r == R) || ...);
+}
+
+template <auto... R>
+constexpr bool EvaluateResultNotIncluded(const Result& r) {
+ return !EvaluateAnyResultIncludes<R...>(r);
+}
+
template <typename T>
constexpr void UpdateCurrentResultReference(T result_reference, Result result) = delete;
// Intentionally not defined
@@ -371,6 +390,13 @@ constexpr void UpdateCurrentResultReference<const Result>(Result result_referenc
DECLARE_CURRENT_RESULT_REFERENCE_AND_STORAGE(__COUNTER__); \
ON_RESULT_SUCCESS_2
+#define ON_RESULT_INCLUDED_2(...) \
+ ON_RESULT_RETURN_IMPL(ResultImpl::EvaluateAnyResultIncludes<__VA_ARGS__>)
+
+#define ON_RESULT_INCLUDED(...) \
+ DECLARE_CURRENT_RESULT_REFERENCE_AND_STORAGE(__COUNTER__); \
+ ON_RESULT_INCLUDED_2(__VA_ARGS__)
+
constexpr inline Result __TmpCurrentResultReference = ResultSuccess;
/// Returns a result.
diff --git a/src/core/hle/service/am/applets/applet_error.cpp b/src/core/hle/service/am/applets/applet_error.cpp
index 5d17c353f..084bc138c 100644
--- a/src/core/hle/service/am/applets/applet_error.cpp
+++ b/src/core/hle/service/am/applets/applet_error.cpp
@@ -27,8 +27,8 @@ struct ErrorCode {
static constexpr ErrorCode FromResult(Result result) {
return {
- .error_category{2000 + static_cast<u32>(result.module.Value())},
- .error_number{result.description.Value()},
+ .error_category{2000 + static_cast<u32>(result.GetModule())},
+ .error_number{result.GetDescription()},
};
}
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index bd4ca753b..05581e6e0 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -139,7 +139,8 @@ private:
ctx.WriteBufferC(performance_buffer.data(), performance_buffer.size(), 1);
}
} else {
- LOG_ERROR(Service_Audio, "RequestUpdate failed error 0x{:02X}!", result.description);
+ LOG_ERROR(Service_Audio, "RequestUpdate failed error 0x{:02X}!",
+ result.GetDescription());
}
IPC::ResponseBuilder rb{ctx, 2};
diff --git a/src/core/hle/service/caps/caps_a.cpp b/src/core/hle/service/caps/caps_a.cpp
index 9925720a3..69acb3a8b 100644
--- a/src/core/hle/service/caps/caps_a.cpp
+++ b/src/core/hle/service/caps/caps_a.cpp
@@ -202,14 +202,14 @@ Result IAlbumAccessorService::TranslateResult(Result in_result) {
}
if ((in_result.raw & 0x3801ff) == ResultUnknown1024.raw) {
- if (in_result.description - 0x514 < 100) {
+ if (in_result.GetDescription() - 0x514 < 100) {
return ResultInvalidFileData;
}
- if (in_result.description - 0x5dc < 100) {
+ if (in_result.GetDescription() - 0x5dc < 100) {
return ResultInvalidFileData;
}
- if (in_result.description - 0x578 < 100) {
+ if (in_result.GetDescription() - 0x578 < 100) {
if (in_result == ResultFileCountLimit) {
return ResultUnknown22;
}
@@ -244,9 +244,10 @@ Result IAlbumAccessorService::TranslateResult(Result in_result) {
return ResultUnknown1024;
}
- if (in_result.module == ErrorModule::FS) {
- if ((in_result.description >> 0xc < 0x7d) || (in_result.description - 1000 < 2000) ||
- (((in_result.description - 3000) >> 3) < 0x271)) {
+ if (in_result.GetModule() == ErrorModule::FS) {
+ if ((in_result.GetDescription() >> 0xc < 0x7d) ||
+ (in_result.GetDescription() - 1000 < 2000) ||
+ (((in_result.GetDescription() - 3000) >> 3) < 0x271)) {
// TODO: Translate FS error
return in_result;
}
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp
index 31da86074..dfcac1ffd 100644
--- a/src/core/hle/service/fatal/fatal.cpp
+++ b/src/core/hle/service/fatal/fatal.cpp
@@ -73,8 +73,8 @@ static void GenerateErrorReport(Core::System& system, Result error_code, const F
"Program entry point: 0x{:16X}\n"
"\n",
Common::g_scm_branch, Common::g_scm_desc, title_id, error_code.raw,
- 2000 + static_cast<u32>(error_code.module.Value()),
- static_cast<u32>(error_code.description.Value()), info.set_flags, info.program_entry_point);
+ 2000 + static_cast<u32>(error_code.GetModule()),
+ static_cast<u32>(error_code.GetDescription()), info.set_flags, info.program_entry_point);
if (info.backtrace_size != 0x0) {
crash_report += "Registers:\n";
for (size_t i = 0; i < info.registers.size(); i++) {
diff --git a/src/core/hle/service/nfc/nfc_interface.cpp b/src/core/hle/service/nfc/nfc_interface.cpp
index 207ac4efe..3e2c7deab 100644
--- a/src/core/hle/service/nfc/nfc_interface.cpp
+++ b/src/core/hle/service/nfc/nfc_interface.cpp
@@ -301,7 +301,7 @@ Result NfcInterface::TranslateResultToServiceError(Result result) const {
return result;
}
- if (result.module != ErrorModule::NFC) {
+ if (result.GetModule() != ErrorModule::NFC) {
return result;
}
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp
index dc3883528..1a0138697 100644
--- a/src/core/reporter.cpp
+++ b/src/core/reporter.cpp
@@ -68,8 +68,8 @@ json GetReportCommonData(u64 title_id, Result result, const std::string& timesta
auto out = json{
{"title_id", fmt::format("{:016X}", title_id)},
{"result_raw", fmt::format("{:08X}", result.raw)},
- {"result_module", fmt::format("{:08X}", static_cast<u32>(result.module.Value()))},
- {"result_description", fmt::format("{:08X}", result.description.Value())},
+ {"result_module", fmt::format("{:08X}", static_cast<u32>(result.GetModule()))},
+ {"result_description", fmt::format("{:08X}", result.GetDescription())},
{"timestamp", timestamp},
};
diff --git a/src/yuzu/applets/qt_error.cpp b/src/yuzu/applets/qt_error.cpp
index 1dc4f0383..ad35f4126 100644
--- a/src/yuzu/applets/qt_error.cpp
+++ b/src/yuzu/applets/qt_error.cpp
@@ -25,8 +25,8 @@ void QtErrorDisplay::ShowError(Result error, FinishedCallback finished) const {
callback = std::move(finished);
emit MainWindowDisplayError(
tr("Error Code: %1-%2 (0x%3)")
- .arg(static_cast<u32>(error.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0'))
- .arg(error.description, 4, 10, QChar::fromLatin1('0'))
+ .arg(static_cast<u32>(error.GetModule()) + 2000, 4, 10, QChar::fromLatin1('0'))
+ .arg(error.GetDescription(), 4, 10, QChar::fromLatin1('0'))
.arg(error.raw, 8, 16, QChar::fromLatin1('0')),
tr("An error has occurred.\nPlease try again or contact the developer of the software."));
}
@@ -38,8 +38,8 @@ void QtErrorDisplay::ShowErrorWithTimestamp(Result error, std::chrono::seconds t
const QDateTime date_time = QDateTime::fromSecsSinceEpoch(time.count());
emit MainWindowDisplayError(
tr("Error Code: %1-%2 (0x%3)")
- .arg(static_cast<u32>(error.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0'))
- .arg(error.description, 4, 10, QChar::fromLatin1('0'))
+ .arg(static_cast<u32>(error.GetModule()) + 2000, 4, 10, QChar::fromLatin1('0'))
+ .arg(error.GetDescription(), 4, 10, QChar::fromLatin1('0'))
.arg(error.raw, 8, 16, QChar::fromLatin1('0')),
tr("An error occurred on %1 at %2.\nPlease try again or contact the developer of the "
"software.")
@@ -53,8 +53,8 @@ void QtErrorDisplay::ShowCustomErrorText(Result error, std::string dialog_text,
callback = std::move(finished);
emit MainWindowDisplayError(
tr("Error Code: %1-%2 (0x%3)")
- .arg(static_cast<u32>(error.module.Value()) + 2000, 4, 10, QChar::fromLatin1('0'))
- .arg(error.description, 4, 10, QChar::fromLatin1('0'))
+ .arg(static_cast<u32>(error.GetModule()) + 2000, 4, 10, QChar::fromLatin1('0'))
+ .arg(error.GetDescription(), 4, 10, QChar::fromLatin1('0'))
.arg(error.raw, 8, 16, QChar::fromLatin1('0')),
tr("An error has occurred.\n\n%1\n\n%2")
.arg(QString::fromStdString(dialog_text))