[DEV] add shared

This commit is contained in:
Edouard DUPIN 2015-01-18 21:04:49 +01:00
parent 4dc0c39470
commit 5c49f39c2e
2 changed files with 38 additions and 5 deletions

View File

@ -12,17 +12,50 @@
#include <etk/types.h>
namespace eci {
class Type {
class Type : public std::enable_shared_from_this<Type> {
protected:
std::string m_signature;
std::string m_signature; // !!! <== specific au language ...
public:
Type() {};
~Type() {};
virtual std::shared_ptr<eci::Variable> operator(const std::shared_ptr<eci::Variable>& _this,
const std::string& _operatorName,
const std::shared_ptr<eci::Variable>& _obj) {
ECI_ERROR("call unknow operator : '" << _operatorName << "'");
return nullptr;
}
virtual std::vector<std::shared_ptr<eci::Variable>> call(const std::shared_ptr<eci::Variable>& _this,
const std::string& _name,
const std::vector<std::shared_ptr<eci::Variable>>& _objList) {
ECI_ERROR("call unknow function : '" << _name << "' with _input.size()=" << _objList.size());
return std::vector<std::shared_ptr<eci::Variable>>();
};
virtual std::shared_ptr<eci::Variable> getVariable(std::shared_ptr<eci::Variable> _this,
const std::string& _name) {
ECI_ERROR("try get unknow Variable : '" << _name << "'");
return nullptr;
};
virtual std::shared_ptr<eci::Variable> create(const std::vector<std::shared_ptr<eci::Variable>>& _obj);
virtual std::shared_ptr<eci::Variable> clone(const std::vector<std::shared_ptr<eci::Variable>>& _obj);
};
template<typename T> class TypeBase {
class TypeNatif : public Type {
protected:
// name , opertor * / += / ++ ...
std::map<std::string, std::function<std::shared_ptr<eci::Variable>, std::shared_ptr<eci::Variable> _variable>> m_operatorList;
// name , function to call
std::map<std::string, std::function<std::vector<std::shared_ptr<eci::Variable>>, std::vector<std::shared_ptr<eci::Variable>> _variable>> m_functionList;
//
};
template<typename T> class TypeBase : public Type {
};
template<> class TypeBase<int32_t> {
}
}
#endif

View File

@ -15,7 +15,7 @@
namespace eci {
class Variable {
class Variable : public std::enable_shared_from_this<Variable> {
public:
Variable();
~Variable();
@ -23,7 +23,7 @@ namespace eci {
enum eci::visibility m_visibility;
bool m_const;
std::string m_name;
eci::Type m_type;
std::shared_ptr<eci::Type> m_type;
};
}