One more file with boost_pp removed
This commit is contained in:
@@ -4,13 +4,6 @@
|
|||||||
// and Jason Turner (jason@emptycrate.com)
|
// and Jason Turner (jason@emptycrate.com)
|
||||||
// http://www.chaiscript.com
|
// http://www.chaiscript.com
|
||||||
|
|
||||||
#include <boost/preprocessor.hpp>
|
|
||||||
|
|
||||||
#define addparam(z,n,text) params.push_back((std::is_reference<Param ## n>::value&&!(std::is_same<chaiscript::Boxed_Value, typename std::remove_const<typename std::remove_reference<Param ## n>::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_
|
#ifndef CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_
|
||||||
#define CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_
|
#define CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_
|
||||||
|
|
||||||
@@ -51,50 +44,41 @@ namespace chaiscript
|
|||||||
dispatch::dispatch(t_funcs, params);
|
dispatch::dispatch(t_funcs, params);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BOOST_PP_ITERATION_LIMITS ( 0, 9 )
|
|
||||||
#define BOOST_PP_FILENAME_1 <chaiscript/dispatchkit/function_call_detail.hpp>
|
|
||||||
#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
|
* used internally for unwrapping a function call's types
|
||||||
*/
|
*/
|
||||||
template<typename Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) >
|
template<typename Ret, typename ... Param>
|
||||||
Ret function_caller(const std::vector<Const_Proxy_Function> &funcs
|
struct Build_Function_Caller_Helper
|
||||||
BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_BINARY_PARAMS(n, Param, p) )
|
|
||||||
{
|
{
|
||||||
std::vector<Boxed_Value> params;
|
Build_Function_Caller_Helper(const std::vector<Const_Proxy_Function> &t_funcs)
|
||||||
|
: m_funcs(t_funcs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_PP_REPEAT(n, addparam, ~)
|
Ret operator()(Param...param)
|
||||||
|
{
|
||||||
|
return Function_Caller_Ret<Ret>::call(m_funcs, {
|
||||||
|
(std::is_reference<Param>::value&&!(std::is_same<chaiscript::Boxed_Value, typename std::remove_const<typename std::remove_reference<Param>::type>::type>::value))?Boxed_Value(std::ref(param)):Boxed_Value(param)...
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
return Function_Caller_Ret<Ret>::call(funcs, params);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
std::vector<Const_Proxy_Function> m_funcs;
|
||||||
* used internally for unwrapping a function call's types
|
};
|
||||||
*/
|
|
||||||
template<typename Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) >
|
|
||||||
std::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param)) >
|
|
||||||
build_function_caller_helper(Ret (BOOST_PP_ENUM_PARAMS(n, Param)), const std::vector<Const_Proxy_Function> &funcs)
|
template<typename Ret, typename ... Params>
|
||||||
|
std::function<Ret (Params...)> build_function_caller_helper(Ret (Params...), const std::vector<Const_Proxy_Function> &funcs)
|
||||||
{
|
{
|
||||||
if (funcs.size() == 1)
|
if (funcs.size() == 1)
|
||||||
{
|
{
|
||||||
std::shared_ptr<const Proxy_Function_Impl<Ret (BOOST_PP_ENUM_PARAMS(n, Param))> > pfi =
|
std::shared_ptr<const Proxy_Function_Impl<Ret (Params...)>> pfi =
|
||||||
std::dynamic_pointer_cast<const Proxy_Function_Impl<Ret (BOOST_PP_ENUM_PARAMS(n, Param))> >
|
std::dynamic_pointer_cast<const Proxy_Function_Impl<Ret (Params...)> >
|
||||||
(funcs[0]);
|
(funcs[0]);
|
||||||
|
|
||||||
if (pfi)
|
if (pfi)
|
||||||
{
|
{
|
||||||
@@ -104,13 +88,11 @@ namespace chaiscript
|
|||||||
// we cannot make any other guesses or assumptions really, so continuing
|
// we cannot make any other guesses or assumptions really, so continuing
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::bind(&function_caller<Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param)>, funcs
|
return std::function<Ret (Params...)>(Build_Function_Caller_Helper<Ret, Params...>(funcs));
|
||||||
BOOST_PP_ENUM_TRAILING(n, curry, ~));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#undef n
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user