diff options
| author | 2017-05-20 20:40:13 -0700 | |
|---|---|---|
| committer | 2017-05-24 21:05:59 -0700 | |
| commit | a75145a2c66808f1c4c905da415f0c9c22172dfd (patch) | |
| tree | ffe5d4edf9cb966535bb149311045b334df779ea /src/core | |
| parent | Merge pull request #2406 from Subv/session_disconnect (diff) | |
| download | yuzu-a75145a2c66808f1c4c905da415f0c9c22172dfd.tar.gz yuzu-a75145a2c66808f1c4c905da415f0c9c22172dfd.tar.xz yuzu-a75145a2c66808f1c4c905da415f0c9c22172dfd.zip | |
Make BitField and ResultCode constexpr-initializable
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/result.h | 33 |
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 { | |||
| 228 | // error | 228 | // error |
| 229 | BitField<31, 1, u32> is_error; | 229 | BitField<31, 1, u32> is_error; |
| 230 | 230 | ||
| 231 | explicit ResultCode(u32 raw) : raw(raw) {} | 231 | constexpr explicit ResultCode(u32 raw) : raw(raw) {} |
| 232 | ResultCode(ErrorDescription description_, ErrorModule module_, ErrorSummary summary_, | 232 | |
| 233 | ErrorLevel level_) | 233 | constexpr ResultCode(ErrorDescription description_, ErrorModule module_, ErrorSummary summary_, |
| 234 | : raw(0) { | 234 | ErrorLevel level_) |
| 235 | description.Assign(description_); | 235 | : raw(description.FormatValue(description_) | module.FormatValue(module_) | |
| 236 | module.Assign(module_); | 236 | summary.FormatValue(summary_) | level.FormatValue(level_)) {} |
| 237 | summary.Assign(summary_); | ||
| 238 | level.Assign(level_); | ||
| 239 | } | ||
| 240 | 237 | ||
| 241 | ResultCode& operator=(const ResultCode& o) { | 238 | constexpr ResultCode& operator=(const ResultCode& o) { |
| 242 | raw = o.raw; | 239 | raw = o.raw; |
| 243 | return *this; | 240 | return *this; |
| 244 | } | 241 | } |
| 245 | 242 | ||
| 246 | bool IsSuccess() const { | 243 | constexpr bool IsSuccess() const { |
| 247 | return is_error == 0; | 244 | return is_error.ExtractValue(raw) == 0; |
| 248 | } | 245 | } |
| 249 | 246 | ||
| 250 | bool IsError() const { | 247 | constexpr bool IsError() const { |
| 251 | return is_error == 1; | 248 | return is_error.ExtractValue(raw) == 1; |
| 252 | } | 249 | } |
| 253 | }; | 250 | }; |
| 254 | 251 | ||
| 255 | inline bool operator==(const ResultCode& a, const ResultCode& b) { | 252 | constexpr bool operator==(const ResultCode& a, const ResultCode& b) { |
| 256 | return a.raw == b.raw; | 253 | return a.raw == b.raw; |
| 257 | } | 254 | } |
| 258 | 255 | ||
| 259 | inline bool operator!=(const ResultCode& a, const ResultCode& b) { | 256 | constexpr bool operator!=(const ResultCode& a, const ResultCode& b) { |
| 260 | return a.raw != b.raw; | 257 | return a.raw != b.raw; |
| 261 | } | 258 | } |
| 262 | 259 | ||
| 263 | // Convenience functions for creating some common kinds of errors: | 260 | // Convenience functions for creating some common kinds of errors: |
| 264 | 261 | ||
| 265 | /// The default success `ResultCode`. | 262 | /// The default success `ResultCode`. |
| 266 | const ResultCode RESULT_SUCCESS(0); | 263 | constexpr ResultCode RESULT_SUCCESS(0); |
| 267 | 264 | ||
| 268 | /// Might be returned instead of a dummy success for unimplemented APIs. | 265 | /// Might be returned instead of a dummy success for unimplemented APIs. |
| 269 | inline ResultCode UnimplementedFunction(ErrorModule module) { | 266 | constexpr ResultCode UnimplementedFunction(ErrorModule module) { |
| 270 | return ResultCode(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported, | 267 | return ResultCode(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported, |
| 271 | ErrorLevel::Permanent); | 268 | ErrorLevel::Permanent); |
| 272 | } | 269 | } |