Move SizedEnum to sead

It is useful in sead and other libraries as well.
This commit is contained in:
Léo Lam 2020-09-06 21:22:30 +02:00
parent 83ad191341
commit 8f3eeb87b9
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
4 changed files with 5 additions and 25 deletions

@ -1 +1 @@
Subproject commit 46ef57b925a24bfb54cbd679a5ecfb413be2d3dc
Subproject commit 71855f048ff11c9520e13377efff2ac1f47166ef

View File

@ -7,6 +7,7 @@
#include <heap/seadDisposer.h>
#include <prim/seadBitFlag.h>
#include <prim/seadScopedLock.h>
#include <prim/seadSizedEnum.h>
#include <thread/seadAtomic.h>
#include <thread/seadCriticalSection.h>
#include "KingSystem/ActorSystem/actBaseProc.h"
@ -176,7 +177,7 @@ private:
static u32 sConstant4;
Status mStatus = Status::Idle;
util::SizedEnum<JobType, u8> mJobType = JobType::Invalid;
sead::SizedEnum<JobType, u8> mJobType = JobType::Invalid;
u8 mCurrentlyProcessingPrio = 8;
u8 mCounter = 0;
sead::CriticalSection mProcMapCS;

View File

@ -4,6 +4,7 @@
#include <basis/seadTypes.h>
#include <math/seadVector.h>
#include <prim/seadSizedEnum.h>
#include "KingSystem/Utils/Types.h"
namespace al {
@ -162,7 +163,7 @@ struct ByamlData {
void set(u8, u32, bool byteswap);
u32 value = 0;
ksys::util::SizedEnum<ByamlType, u8> type = ByamlType::Invalid;
sead::SizedEnum<ByamlType, u8> type = ByamlType::Invalid;
};
bool tryGetByamlS32(s32* value, const ByamlIter& iter, const char* key);

View File

@ -7,25 +7,3 @@
#else
#define KSYS_CHECK_SIZE_NX150(CLASS, SIZE) static_assert(sizeof(CLASS) == SIZE)
#endif
namespace ksys::util {
/// For storing an enum with a particular storage size when specifying the underlying type of the
/// enum is not an option.
template <typename Enum, typename Storage>
struct SizedEnum {
static_assert(std::is_enum<Enum>());
static_assert(!std::is_enum<Storage>());
constexpr SizedEnum() = default;
constexpr SizedEnum(Enum value) { *this = value; }
constexpr operator Enum() const { return static_cast<Enum>(mValue); }
constexpr SizedEnum& operator=(Enum value) {
mValue = static_cast<Storage>(value);
return *this;
}
Storage mValue;
};
} // namespace ksys::util