diff --git a/include/chaiscript/dispatchkit/function_call_detail.hpp b/include/chaiscript/dispatchkit/function_call_detail.hpp index e5312055..15ffaf34 100644 --- a/include/chaiscript/dispatchkit/function_call_detail.hpp +++ b/include/chaiscript/dispatchkit/function_call_detail.hpp @@ -4,13 +4,6 @@ // and Jason Turner (jason@emptycrate.com) // http://www.chaiscript.com -#include - -#define addparam(z,n,text) params.push_back((std::is_reference::value&&!(std::is_same::type>::type>::value))?Boxed_Value(std::ref(BOOST_PP_CAT(p, n))):Boxed_Value(BOOST_PP_CAT(p, n) )); -#define curry(z,n,text) BOOST_PP_CAT(std::placeholders::_, BOOST_PP_INC(n)) - - -#ifndef BOOST_PP_IS_ITERATING #ifndef CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_ #define CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_ @@ -51,50 +44,41 @@ namespace chaiscript dispatch::dispatch(t_funcs, params); } }; - } - } -} -#define BOOST_PP_ITERATION_LIMITS ( 0, 9 ) -#define BOOST_PP_FILENAME_1 -#include BOOST_PP_ITERATE() - -# endif -#else -# define n BOOST_PP_ITERATION() - -namespace chaiscript -{ - namespace dispatch - { - namespace detail - { /** * used internally for unwrapping a function call's types */ - template - Ret function_caller(const std::vector &funcs - BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_BINARY_PARAMS(n, Param, p) ) + template + struct Build_Function_Caller_Helper { - std::vector params; + Build_Function_Caller_Helper(const std::vector &t_funcs) + : m_funcs(t_funcs) + { + } - BOOST_PP_REPEAT(n, addparam, ~) + Ret operator()(Param...param) + { + return Function_Caller_Ret::call(m_funcs, { +(std::is_reference::value&&!(std::is_same::type>::type>::value))?Boxed_Value(std::ref(param)):Boxed_Value(param)... + } + + ); - return Function_Caller_Ret::call(funcs, params); - } + } - /** - * used internally for unwrapping a function call's types - */ - template - std::function - build_function_caller_helper(Ret (BOOST_PP_ENUM_PARAMS(n, Param)), const std::vector &funcs) + std::vector m_funcs; + }; + + + + template + std::function build_function_caller_helper(Ret (Params...), const std::vector &funcs) { if (funcs.size() == 1) { - std::shared_ptr > pfi = - std::dynamic_pointer_cast > - (funcs[0]); + std::shared_ptr> pfi = + std::dynamic_pointer_cast > + (funcs[0]); if (pfi) { @@ -104,13 +88,11 @@ namespace chaiscript // we cannot make any other guesses or assumptions really, so continuing } - return std::bind(&function_caller, funcs - BOOST_PP_ENUM_TRAILING(n, curry, ~)); + return std::function(Build_Function_Caller_Helper(funcs)); } } } } -#undef n #endif