wut  v1.7.0
Wii U Toolchain
result.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 
11 typedef struct NNResult NNResult;
12 
19 struct NNResult
20 {
22  int32_t value;
23 };
24 
37 static inline int NNResult_IsSuccess(NNResult result)
38 {
39  return result.value >= 0;
40 }
41 
54 static inline int NNResult_IsFailure(NNResult result)
55 {
56  return result.value < 0;
57 }
58 
59 #ifdef __cplusplus
60 
61 namespace nn
62 {
63 
67 class Result
68 {
69 public:
70  enum Level
71  {
76  LEVEL_END = -7,
77  };
78 
80  {
86  };
87 
88  enum Module
89  {
119  };
120 
122  {
140  MODULE_NN_FS = 0x11,
141  MODULE_NN_DI = 0x12,
144  MODULE_NN_PI = 0x15,
145  MODULE_NN_PM = 0x16,
155  MODULE_NN_AM = 0x20,
160  MODULE_NN_MP = 0x25,
162  MODULE_NN_AC = 0x27,
178  MODULE_NN_MC = 0x37,
188  MODULE_NN_PS = 0x41,
190  MODULE_NN_IR = 0x43,
192  MODULE_NN_PL = 0x45,
196  MODULE_NN_NS = 0x49,
198  MODULE_NN_RO = 0x4B,
199  MODULE_NN_GD = 0x4C,
201  MODULE_NN_EC = 0x4E,
207  };
208 
210  {
223  };
224 
226  {
228  };
229 
230 public:
231  Result(Level level, Module module, unsigned description) :
232  mValue(((level & 0x7) << 29) | ((module & 0x1FF) << 20) | (description & 0xFFFFF))
233  {
234  }
235 
236  Result(const NNResult &result) :
237  mValue(result.value)
238  {
239  }
240 
250  bool IsFailure() const
251  {
252  return !IsSuccess();
253  }
254 
264  bool IsSuccess() const
265  {
266  return mValue >= 0; // level >= 0
267  }
268 
269  bool IsLegacy() const
270  {
271  return ((mValue >> 27) & 0x3) == SIGNATURE_IS_LEGACY;
272  }
273 
274  unsigned GetDescription() const
275  {
276  return mValue & (IsLegacy() ? 0x3FF : 0xFFFFF);
277  }
278 
279  int GetLevel() const
280  {
281  if (IsLegacy()) {
282  return (mValue << 14) >> 28; // cause arithmetic shift
283  }
284 
285  return mValue >> 29;
286  }
287 
288  unsigned GetModule() const
289  {
290  return (mValue >> 20) & (IsLegacy() ? 0x7F : 0x1FF);
291  }
292 
293  unsigned GetSummary() const
294  {
295  if (IsLegacy()) {
296  return (mValue >> 10) & 0xF;
297  }
298 
299  return 0;
300  }
301 
302  operator bool() const
303  {
304  return IsSuccess();
305  }
306 
307  operator NNResult() const
308  {
309  NNResult result;
310  result.value = mValue;
311  return result;
312  }
313 
314  bool operator==(const Result &other) const
315  {
316  return mValue == other.mValue;
317  }
318 
319  bool operator!=(const Result &other) const
320  {
321  return mValue != other.mValue;
322  }
323 
324 private:
325  int32_t mValue;
326 };
327 
328 } // namespace nn
329 
330 #endif // ifdef __cplusplus
331 
Result value type used by nn libraries.
Definition: result.h:68
LegacySignature
Definition: result.h:226
@ SIGNATURE_IS_LEGACY
Definition: result.h:227
@ LEVEL_STATUS
Definition: result.h:75
@ LEVEL_FATAL
Definition: result.h:73
@ LEVEL_USAGE
Definition: result.h:74
@ LEVEL_END
Definition: result.h:76
@ LEVEL_SUCCESS
Definition: result.h:72
LegacySummary
Definition: result.h:210
@ SUMMARY_NOTHING_HAPPENED
Definition: result.h:212
@ SUMMARY_NOT_SUPPORTED
Definition: result.h:217
@ SUMMARY_SUCCESS
Definition: result.h:211
@ SUMMARY_INVALID_ARGUMENT
Definition: result.h:218
@ SUMMARY_INTERNAL
Definition: result.h:222
@ SUMMARY_NOT_FOUND
Definition: result.h:215
@ SUMMARY_STATUS_CHANGED
Definition: result.h:221
@ SUMMARY_OUT_OF_RESOURCE
Definition: result.h:214
@ SUMMARY_CANCELLED
Definition: result.h:220
@ SUMMARY_WOULD_BLOCK
Definition: result.h:213
@ SUMMARY_WRONG_ARGUMENT
Definition: result.h:219
@ SUMMARY_INVALID_STATE
Definition: result.h:216
bool IsSuccess() const
Determine if the Result instance represents a successful state.
Definition: result.h:264
LegacyLevel
Definition: result.h:80
@ LEVEL_RESET
Definition: result.h:82
@ LEVEL_INFO
Definition: result.h:81
@ LEVEL_PERMANENT
Definition: result.h:84
@ LEVEL_TEMPORARY
Definition: result.h:85
@ LEVEL_REINIT
Definition: result.h:83
unsigned GetDescription() const
Definition: result.h:274
bool IsFailure() const
Determine if the Result instance represents a failure.
Definition: result.h:250
int GetLevel() const
Definition: result.h:279
@ RESULT_MODULE_NN_IPC
Definition: result.h:91
@ RESULT_MODULE_NN_CONNTEST
Definition: result.h:104
@ RESULT_MODULE_NN_EC
Definition: result.h:112
@ RESULT_MODULE_NN_TEST
Definition: result.h:118
@ RESULT_MODULE_NN_PDM
Definition: result.h:96
@ RESULT_MODULE_NN_DRMAPP
Definition: result.h:105
@ RESULT_MODULE_NN_SPM
Definition: result.h:110
@ RESULT_MODULE_NN_ACP
Definition: result.h:93
@ RESULT_MODULE_NN_EMD
Definition: result.h:111
@ RESULT_MODULE_NN_SL
Definition: result.h:114
@ RESULT_MODULE_NN_FP
Definition: result.h:102
@ RESULT_MODULE_NN_NGC
Definition: result.h:98
@ RESULT_MODULE_COMMON
Definition: result.h:90
@ RESULT_MODULE_NN_NUP
Definition: result.h:100
@ RESULT_MODULE_NN_NDM
Definition: result.h:101
@ RESULT_MODULE_NN_BOSS
Definition: result.h:92
@ RESULT_MODULE_NN_VCTL
Definition: result.h:108
@ RESULT_MODULE_NN_NEIA
Definition: result.h:109
@ RESULT_MODULE_NN_ECO
Definition: result.h:115
@ RESULT_MODULE_NN_IOS
Definition: result.h:94
@ RESULT_MODULE_NN_AC
Definition: result.h:103
@ RESULT_MODULE_NN_TELNET
Definition: result.h:106
@ RESULT_MODULE_NN_NFP
Definition: result.h:117
@ RESULT_MODULE_NN_CIA
Definition: result.h:113
@ RESULT_MODULE_NN_TRIAL
Definition: result.h:116
@ RESULT_MODULE_NN_ACT
Definition: result.h:97
@ RESULT_MODULE_NN_OLV
Definition: result.h:107
@ RESULT_MODULE_NN_NIM
Definition: result.h:95
@ RESULT_MODULE_NN_ECA
Definition: result.h:99
unsigned GetModule() const
Definition: result.h:288
Result(Level level, Module module, unsigned description)
Definition: result.h:231
bool operator!=(const Result &other) const
Definition: result.h:319
bool IsLegacy() const
Definition: result.h:269
bool operator==(const Result &other) const
Definition: result.h:314
Result(const NNResult &result)
Definition: result.h:236
unsigned GetSummary() const
Definition: result.h:293
LegacyModule
Definition: result.h:122
@ MODULE_NN_TEST
Definition: result.h:203
@ MODULE_NN_MCU
Definition: result.h:195
@ MODULE_NN_CODEC
Definition: result.h:137
@ MODULE_NN_SOCKET
Definition: result.h:151
@ MODULE_NN_AMLOW
Definition: result.h:170
@ MODULE_NN_HTTP
Definition: result.h:163
@ MODULE_NN_CFG
Definition: result.h:187
@ MODULE_NN_NIM
Definition: result.h:175
@ MODULE_NN_SRV
Definition: result.h:148
@ MODULE_NN_UPDATER
Definition: result.h:157
@ MODULE_NN_SSL
Definition: result.h:169
@ MODULE_NN_SND
Definition: result.h:165
@ MODULE_NN_NEX
Definition: result.h:171
@ MODULE_NN_EC
Definition: result.h:201
@ MODULE_NN_UDS
Definition: result.h:191
@ MODULE_NN_CAMERA
Definition: result.h:143
@ MODULE_NN_DMNT
Definition: result.h:131
@ MODULE_NN_HIO
Definition: result.h:156
@ MODULE_NN_SPI
Definition: result.h:138
@ MODULE_NN_DSP
Definition: result.h:164
@ MODULE_NN_GYROSCOPE
Definition: result.h:194
@ MODULE_NN_PXI
Definition: result.h:139
@ MODULE_NN_DBM
Definition: result.h:186
@ MODULE_NN_FS
Definition: result.h:140
@ MODULE_NN_DI
Definition: result.h:141
@ MODULE_NN_MC
Definition: result.h:178
@ MODULE_NN_RO
Definition: result.h:198
@ MODULE_NN_FND
Definition: result.h:159
@ MODULE_NN_PL
Definition: result.h:192
@ MODULE_NN_PIA
Definition: result.h:205
@ MODULE_NN_DLP
Definition: result.h:166
@ MODULE_NN_IR
Definition: result.h:190
@ MODULE_NN_NEWS
Definition: result.h:197
@ MODULE_NN_CARDSPI
Definition: result.h:200
@ MODULE_NN_LOADER_SERVER
Definition: result.h:127
@ MODULE_NN_FSI
Definition: result.h:147
@ MODULE_NN_OS
Definition: result.h:129
@ MODULE_NN_RDT
Definition: result.h:173
@ MODULE_NN_ROMFS
Definition: result.h:154
@ MODULE_NN_NDM
Definition: result.h:149
@ MODULE_NN_NWM
Definition: result.h:150
@ MODULE_NN_CEC
Definition: result.h:189
@ MODULE_NN_DBG
Definition: result.h:130
@ MODULE_NN_LDR
Definition: result.h:152
@ MODULE_NN_NS
Definition: result.h:196
@ MODULE_NN_CUP
Definition: result.h:193
@ MODULE_NN_CARD
Definition: result.h:182
@ MODULE_NN_NGC
Definition: result.h:181
@ MODULE_NN_GX
Definition: result.h:133
@ MODULE_NN_PMLOW
Definition: result.h:146
@ MODULE_NN_PS
Definition: result.h:188
@ MODULE_NN_FRIENDS
Definition: result.h:172
@ MODULE_NN_UTIL
Definition: result.h:125
@ MODULE_NN_ENC
Definition: result.h:204
@ MODULE_NN_I2C
Definition: result.h:134
@ MODULE_NN_MPWL
Definition: result.h:161
@ MODULE_NN_ACC
Definition: result.h:153
@ MODULE_NN_FATFS
Definition: result.h:180
@ MODULE_NN_FILE_SERVER
Definition: result.h:126
@ MODULE_NN_GD
Definition: result.h:199
@ MODULE_NN_GPIO
Definition: result.h:135
@ MODULE_NN_SDMC
Definition: result.h:184
@ MODULE_NN_WEBBRS
Definition: result.h:202
@ MODULE_NN_CSND
Definition: result.h:168
@ MODULE_NN_MIC
Definition: result.h:158
@ MODULE_NN_PDN
Definition: result.h:132
@ MODULE_NN_HIOLOW
Definition: result.h:167
@ MODULE_NN_CARDNOR
Definition: result.h:183
@ MODULE_NN_MIDI
Definition: result.h:177
@ MODULE_APPLICATION
Definition: result.h:206
@ MODULE_NN_BOSS
Definition: result.h:185
@ MODULE_NN_APPLET
Definition: result.h:174
@ MODULE_NN_DD
Definition: result.h:136
@ MODULE_NN_TCB
Definition: result.h:128
@ MODULE_NN_PI
Definition: result.h:144
@ MODULE_NN_PTM
Definition: result.h:176
@ MODULE_NN_KERNEL
Definition: result.h:124
@ MODULE_NN_AC
Definition: result.h:162
@ MODULE_NN_PM
Definition: result.h:145
@ MODULE_NN_MP
Definition: result.h:160
@ MODULE_NN_HID
Definition: result.h:142
@ MODULE_NN_SWC
Definition: result.h:179
@ MODULE_COMMON
Definition: result.h:123
@ MODULE_NN_AM
Definition: result.h:155
int32_t value
Aggregate value of result bitfield.
Definition: result.h:22
static int NNResult_IsFailure(NNResult result)
Determine if a NNResult represents a failure.
Definition: result.h:54
static int NNResult_IsSuccess(NNResult result)
Determine if a NNResult represents a successful state.
Definition: result.h:37
struct NNResult NNResult
Definition: result.h:11
Result structure for nn libraries.
Definition: result.h:20
Definition: ac_cpp.h:15