33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
|
|
#include "UserData.hpp"
|
|
#include "UserDataStorage.hpp"
|
|
|
|
namespace Porygon::UserData {
|
|
extern "C" {
|
|
void RegisterUserDataType(char16_t * key) {
|
|
auto hashedKey = new Utilities::HashedString(new u16string(key));
|
|
auto ud = new UserData(hashedKey, {});
|
|
UserDataStorage::RegisterType(hashedKey->GetHash(), ud);
|
|
}
|
|
|
|
void RegisterUserDataField(uint32_t typeId, uint32_t fieldId, UserDataField *field) {
|
|
auto ud = UserDataStorage::GetUserDataType(typeId);
|
|
ud->Get()->CreateField(fieldId, field);
|
|
}
|
|
|
|
int32_t GetUserDataFieldCount(uint32_t typeId) {
|
|
auto ud = UserDataStorage::GetUserDataType(typeId);
|
|
return ud->Get()->GetFieldCount();
|
|
}
|
|
|
|
void SetIsCastableFunc(uint32_t typeId, bool (*cast)(const ScriptType*, bool)){
|
|
auto ud = UserDataStorage::GetUserDataType(typeId);
|
|
ud->Get()->SetIsCastable(cast);
|
|
}
|
|
|
|
void SetCastFunc(uint32_t typeId, Evaluation::EvalValue* (*cast)(void*, const ScriptType*)){
|
|
auto ud = UserDataStorage::GetUserDataType(typeId);
|
|
ud->Get()->SetCastFunc(cast);
|
|
}
|
|
}
|
|
} |