PorygonLang/src/UserData/UserDataField.hpp

35 lines
792 B
C++
Raw Normal View History

2019-06-14 12:59:38 +00:00
#ifndef PORYGONLANG_USERDATAFIELD_HPP
#define PORYGONLANG_USERDATAFIELD_HPP
#include "../Evaluator/EvalValues/EvalValue.hpp"
#include "../Evaluator/EvalValues/NumericEvalValue.hpp"
2019-06-14 12:59:38 +00:00
class UserDataField {
shared_ptr<ScriptType> _type;
EvalValue* (*_get)(void* obj);
void (*_set)(void* obj, EvalValue*);
public:
UserDataField(ScriptType* type, EvalValue* (*getter)(void* obj), void (*setter)(void* obj, EvalValue*)){
_type = shared_ptr<ScriptType>(type);
_get = getter;
_set = setter;
}
shared_ptr<ScriptType> GetType(){
return _type;
}
EvalValue* Get(void* obj){
return this ->_get(obj);
}
void Set(void* obj, EvalValue* val){
this->_set(obj, val);
}
};
#endif //PORYGONLANG_USERDATAFIELD_HPP