Mark evalValues as const
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
#ifndef PORYGONLANG_USERDATAVALUE_HPP
|
||||
#define PORYGONLANG_USERDATAVALUE_HPP
|
||||
|
||||
@@ -9,49 +8,51 @@
|
||||
#include "UserDataStorage.hpp"
|
||||
|
||||
class UserDataValue : public EvalValue{
|
||||
shared_ptr<UserData> _userData;
|
||||
const shared_ptr<UserData> _userData;
|
||||
void* _obj;
|
||||
public:
|
||||
UserDataValue(shared_ptr<UserData> userData, void* obj){
|
||||
_userData = std::move(userData);
|
||||
UserDataValue(shared_ptr<UserData> userData, void* obj)
|
||||
: _userData(std::move(userData))
|
||||
{
|
||||
_obj = obj;
|
||||
}
|
||||
|
||||
UserDataValue(uint32_t userDataId, void* obj){
|
||||
_userData = UserDataStorage::GetUserDataType(userDataId);
|
||||
UserDataValue(uint32_t userDataId, void* obj)
|
||||
: _userData(UserDataStorage::GetUserDataType(userDataId))
|
||||
{
|
||||
_obj = obj;
|
||||
}
|
||||
|
||||
const TypeClass GetTypeClass() final{
|
||||
const TypeClass GetTypeClass() const final{
|
||||
return TypeClass ::UserData;
|
||||
}
|
||||
|
||||
bool operator ==(EvalValue* b) final {
|
||||
const bool operator ==(EvalValue* b) const final {
|
||||
if (b->GetTypeClass() != TypeClass::UserData)
|
||||
return false;
|
||||
return _obj == ((UserDataValue*)b)->_obj;
|
||||
}
|
||||
|
||||
shared_ptr<EvalValue> Clone() final{
|
||||
const shared_ptr<EvalValue> Clone() const final{
|
||||
return make_shared<UserDataValue>(_userData, _obj);
|
||||
}
|
||||
|
||||
std::size_t GetHashCode() final{
|
||||
const std::size_t GetHashCode() const final{
|
||||
return reinterpret_cast<intptr_t>(_obj);
|
||||
}
|
||||
|
||||
shared_ptr<EvalValue> IndexValue(EvalValue* val) final {
|
||||
const shared_ptr<EvalValue> IndexValue(EvalValue* val) const final {
|
||||
auto fieldId = val->GetHashCode();
|
||||
auto field = _userData->GetField(fieldId);
|
||||
return shared_ptr<EvalValue>(field->Get(_obj));
|
||||
}
|
||||
|
||||
shared_ptr<EvalValue> IndexValue(uint32_t hash) final{
|
||||
const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final{
|
||||
auto field = _userData->GetField(hash);
|
||||
return shared_ptr<EvalValue>(field->Get(_obj));
|
||||
}
|
||||
|
||||
void SetIndexValue(EvalValue *key, shared_ptr<EvalValue> value) final{
|
||||
void SetIndexValue(EvalValue *key, const shared_ptr<EvalValue>& value) const final{
|
||||
auto fieldId = key->GetHashCode();
|
||||
auto field = _userData->GetField(fieldId);
|
||||
field -> Set(_obj, value.get());
|
||||
|
||||
Reference in New Issue
Block a user