summaryrefslogtreecommitdiffstats
path: root/src/core/hle/result.h
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-05-21 05:40:13 +0200
committerYuri Kunde Schlesner <yuriks@yuriks.net>2017-05-25 06:05:59 +0200
commita75145a2c66808f1c4c905da415f0c9c22172dfd (patch)
treeffe5d4edf9cb966535bb149311045b334df779ea /src/core/hle/result.h
parentMerge pull request #2406 from Subv/session_disconnect (diff)
downloadyuzu-a75145a2c66808f1c4c905da415f0c9c22172dfd.tar
yuzu-a75145a2c66808f1c4c905da415f0c9c22172dfd.tar.gz
yuzu-a75145a2c66808f1c4c905da415f0c9c22172dfd.tar.bz2
yuzu-a75145a2c66808f1c4c905da415f0c9c22172dfd.tar.lz
yuzu-a75145a2c66808f1c4c905da415f0c9c22172dfd.tar.xz
yuzu-a75145a2c66808f1c4c905da415f0c9c22172dfd.tar.zst
yuzu-a75145a2c66808f1c4c905da415f0c9c22172dfd.zip
Diffstat (limited to 'src/core/hle/result.h')
-rw-r--r--src/core/hle/result.h33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index 13b948871..db548bd76 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -228,45 +228,42 @@ union ResultCode {
// error
BitField<31, 1, u32> is_error;
- explicit ResultCode(u32 raw) : raw(raw) {}
- ResultCode(ErrorDescription description_, ErrorModule module_, ErrorSummary summary_,
- ErrorLevel level_)
- : raw(0) {
- description.Assign(description_);
- module.Assign(module_);
- summary.Assign(summary_);
- level.Assign(level_);
- }
+ constexpr explicit ResultCode(u32 raw) : raw(raw) {}
+
+ constexpr ResultCode(ErrorDescription description_, ErrorModule module_, ErrorSummary summary_,
+ ErrorLevel level_)
+ : raw(description.FormatValue(description_) | module.FormatValue(module_) |
+ summary.FormatValue(summary_) | level.FormatValue(level_)) {}
- ResultCode& operator=(const ResultCode& o) {
+ constexpr ResultCode& operator=(const ResultCode& o) {
raw = o.raw;
return *this;
}
- bool IsSuccess() const {
- return is_error == 0;
+ constexpr bool IsSuccess() const {
+ return is_error.ExtractValue(raw) == 0;
}
- bool IsError() const {
- return is_error == 1;
+ constexpr bool IsError() const {
+ return is_error.ExtractValue(raw) == 1;
}
};
-inline bool operator==(const ResultCode& a, const ResultCode& b) {
+constexpr bool operator==(const ResultCode& a, const ResultCode& b) {
return a.raw == b.raw;
}
-inline bool operator!=(const ResultCode& a, const ResultCode& b) {
+constexpr bool operator!=(const ResultCode& a, const ResultCode& b) {
return a.raw != b.raw;
}
// Convenience functions for creating some common kinds of errors:
/// The default success `ResultCode`.
-const ResultCode RESULT_SUCCESS(0);
+constexpr ResultCode RESULT_SUCCESS(0);
/// Might be returned instead of a dummy success for unimplemented APIs.
-inline ResultCode UnimplementedFunction(ErrorModule module) {
+constexpr ResultCode UnimplementedFunction(ErrorModule module) {
return ResultCode(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported,
ErrorLevel::Permanent);
}