mirror of
https://github.com/wiiu-env/wut.git
synced 2024-12-05 03:24:17 +01:00
Fixing nn::Result
Bit fields work, but suffer order changes with endianness Was properly done for little endian, but not big endian Swapped to shifts instead for general portability too
This commit is contained in:
parent
59b83dac23
commit
1282cbbda3
@ -222,9 +222,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Result(Level level, Module module, unsigned description) :
|
Result(Level level, Module module, unsigned description) :
|
||||||
mDescription(description),
|
mValue(((level & 0x7) << 29) | ((module & 0x1FF) << 20) | (description & 0xFFFFF))
|
||||||
mModule(module),
|
|
||||||
mLevel(level)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,45 +256,37 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool IsSuccess() const
|
bool IsSuccess() const
|
||||||
{
|
{
|
||||||
return mLevel >= 0;
|
return mValue >= 0; // level >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsLegacy() const
|
bool IsLegacy() const
|
||||||
{
|
{
|
||||||
return mLegacy.signature == SIGNATURE_IS_LEGACY;
|
return ((mValue >> 27) & 0x3) == SIGNATURE_IS_LEGACY;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned GetDescription() const
|
unsigned GetDescription() const
|
||||||
{
|
{
|
||||||
if (IsLegacy()) {
|
return mValue & (IsLegacy() ? 0x3FF : 0xFFFFF);
|
||||||
return mLegacy.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mDescription;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetLevel() const
|
int GetLevel() const
|
||||||
{
|
{
|
||||||
if (IsLegacy()) {
|
if (IsLegacy()) {
|
||||||
return mLegacy.level;
|
return (mValue << 14) >> 28; // cause arithmetic shift
|
||||||
}
|
}
|
||||||
|
|
||||||
return mLevel;
|
return mValue >> 29;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned GetModule() const
|
unsigned GetModule() const
|
||||||
{
|
{
|
||||||
if (IsLegacy()) {
|
return (mValue >> 20) & (IsLegacy() ? 0x7F : 0x1FF);
|
||||||
return mLegacy.module;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mModule;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned GetSummary() const
|
unsigned GetSummary() const
|
||||||
{
|
{
|
||||||
if (IsLegacy()) {
|
if (IsLegacy()) {
|
||||||
return mLegacy.summary;
|
return (mValue >> 10) & 0xF;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -325,24 +315,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
union {
|
int32_t mValue;
|
||||||
struct {
|
|
||||||
uint32_t description : 10;
|
|
||||||
uint32_t summary : 4;
|
|
||||||
int32_t level : 4;
|
|
||||||
uint32_t : 2;
|
|
||||||
uint32_t module : 7;
|
|
||||||
uint32_t signature : 2;
|
|
||||||
} mLegacy;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
uint32_t mDescription : 20;
|
|
||||||
uint32_t mModule : 9;
|
|
||||||
int32_t mLevel : 3;
|
|
||||||
};
|
|
||||||
|
|
||||||
int32_t mValue;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace nn
|
} // namespace nn
|
||||||
|
Loading…
Reference in New Issue
Block a user