// This file is distributed under the BSD License. // See "license.txt" for details. // Copyright 2009, Jonathan Turner (jturner@minnow-lang.org) // and Jason Turner (lefticus@gmail.com) // http://www.chaiscript.com #include #define addparam(z,n,text) params.push_back(boost::is_reference::value?Boxed_Value(boost::ref(BOOST_PP_CAT(p, n))):Boxed_Value(BOOST_PP_CAT(p, n) )); #define curry(z,n,text) BOOST_PP_CAT(_, BOOST_PP_INC(n)) #ifndef BOOST_PP_IS_ITERATING #ifndef __function_call_detail_hpp__ #define __function_call_detail_hpp__ #include #include #include #include #include #include "proxy_functions.hpp" namespace chaiscript { namespace detail { /** * Internal helper class for handling the return * value of a build_function_caller */ template struct Function_Caller_Ret { static Ret call(const std::vector > &t_funcs, const std::vector ¶ms) { return boxed_cast(dispatch(t_funcs, params)); } }; /** * Specialization for void return types */ template<> struct Function_Caller_Ret { static void call(const std::vector > &t_funcs, const std::vector ¶ms) { 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 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) ) { std::vector params; BOOST_PP_REPEAT(n, addparam, ~) return Function_Caller_Ret::call(funcs, params); } /** * used internally for unwrapping a function call's types */ template boost::function build_function_caller_helper(Ret (BOOST_PP_ENUM_PARAMS(n, Param)), const std::vector > &funcs) { return boost::bind(&function_caller, funcs BOOST_PP_ENUM_TRAILING(n, curry, ~)); } } } #endif