// This file is distributed under the BSD License. // See "license.txt" for details. // Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com) // Copyright 2009-2018, Jason Turner (jason@emptycrate.com) // http://www.chaiscript.com #ifndef CHAISCRIPT_CALLABLE_TRAITS_HPP_ #define CHAISCRIPT_CALLABLE_TRAITS_HPP_ #include namespace chaiscript { namespace dispatch { namespace detail { template struct Constructor { template std::shared_ptr operator()(Inner &&...inner) const { return std::make_shared(std::forward(inner)...); } }; template struct Const_Caller { explicit Const_Caller(Ret (Class::*t_func)(Param...) const) : m_func(t_func) { } template Ret operator()(const Class &o, Inner &&...inner) const { return (o.*m_func)(std::forward(inner)...); } Ret (Class::*m_func)(Param...) const; }; template struct Fun_Caller { explicit Fun_Caller(Ret (*t_func)(Param...)) : m_func(t_func) { } template Ret operator()(Inner &&...inner) const { return (m_func)(std::forward(inner)...); } Ret (*m_func)(Param...); }; template struct Caller { explicit Caller(Ret (Class::*t_func)(Param...)) : m_func(t_func) { } template Ret operator()(Class &o, Inner &&...inner) const { return (o.*m_func)(std::forward(inner)...); } Ret (Class::*m_func)(Param...); }; template struct Arity { }; template struct Arity { static const size_t arity = sizeof...(Params); }; template struct Function_Signature { }; template struct Function_Signature { using Return_Type = Ret; using Signature = Ret()(Params...); }; template struct Function_Signature { using Return_Type = Ret; using Signature = Ret()(Params...); }; template struct Callable_Traits { using Signature = typename Function_Signature::Signature; using Return_Type = typename Function_Signature::Return_Type; }; } // namespace detail } // namespace dispatch } // namespace chaiscript #endif