34 lines
736 B
C++
34 lines
736 B
C++
|
|
||
|
#ifndef PORYGONLANG_USERDATAFIELD_HPP
|
||
|
#define PORYGONLANG_USERDATAFIELD_HPP
|
||
|
|
||
|
|
||
|
#include "../Evaluator/EvalValues/EvalValue.hpp"
|
||
|
|
||
|
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
|