Move "fun_helper" into detail namespace
This commit is contained in:
parent
bc3a17b3b7
commit
00e4de774f
@ -16,19 +16,6 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
template<typename T>
|
|
||||||
Proxy_Function fun(T t)
|
|
||||||
{
|
|
||||||
return fun_helper(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
Proxy_Function fun_helper(const boost::function<T> &f)
|
|
||||||
{
|
|
||||||
return Proxy_Function(new Proxy_Function_Impl<T>(f));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -39,57 +26,76 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
return (obj->*m);
|
return (obj->*m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Proxy_Function fun_helper(const boost::function<T> &f)
|
||||||
|
{
|
||||||
|
return Proxy_Function(new Proxy_Function_Impl<T>(f));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatically create a get_member helper function for an object
|
||||||
|
* to allow for runtime dispatched access to public data members
|
||||||
|
* for example, the case of std::pair<>::first and std::pair<>::second
|
||||||
|
*/
|
||||||
|
template<typename T, typename Class>
|
||||||
|
Proxy_Function fun_helper(T Class::* m)
|
||||||
|
{
|
||||||
|
return fun_helper(boost::function<T& (Class *)>(boost::bind(&detail::get_member<T, Class>, m, _1)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically create a get_member helper function for an object
|
|
||||||
* to allow for runtime dispatched access to public data members
|
|
||||||
* for example, the case of std::pair<>::first and std::pair<>::second
|
|
||||||
*/
|
|
||||||
template<typename T, typename Class>
|
|
||||||
Proxy_Function fun_helper(T Class::* m)
|
|
||||||
{
|
|
||||||
return fun_helper(boost::function<T& (Class *)>(boost::bind(&detail::get_member<T, Class>, m, _1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BOOST_PP_ITERATION_LIMITS ( 0, 10 )
|
#define BOOST_PP_ITERATION_LIMITS ( 0, 10 )
|
||||||
#define BOOST_PP_FILENAME_1 <chaiscript/dispatchkit/register_function.hpp>
|
#define BOOST_PP_FILENAME_1 <chaiscript/dispatchkit/register_function.hpp>
|
||||||
#include BOOST_PP_ITERATE()
|
#include BOOST_PP_ITERATE()
|
||||||
|
|
||||||
|
namespace chaiscript
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
Proxy_Function fun(T t)
|
||||||
|
{
|
||||||
|
return detail::fun_helper(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define n BOOST_PP_ITERATION()
|
# define n BOOST_PP_ITERATION()
|
||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
/**
|
namespace detail
|
||||||
* Register a global function of n parameters with name
|
{
|
||||||
*/
|
/**
|
||||||
template<typename Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)>
|
* Register a global function of n parameters with name
|
||||||
Proxy_Function fun_helper(Ret (*f)(BOOST_PP_ENUM_PARAMS(n, Param)))
|
*/
|
||||||
{
|
template<typename Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)>
|
||||||
return fun_helper(boost::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param))>(f));
|
Proxy_Function fun_helper(Ret (*f)(BOOST_PP_ENUM_PARAMS(n, Param)))
|
||||||
}
|
{
|
||||||
|
return fun_helper(boost::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param))>(f));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a class method of n parameters with name
|
* Register a class method of n parameters with name
|
||||||
*/
|
*/
|
||||||
template<typename Ret, typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)>
|
template<typename Ret, typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)>
|
||||||
Proxy_Function fun_helper(Ret (Class::*f)(BOOST_PP_ENUM_PARAMS(n, Param)))
|
Proxy_Function fun_helper(Ret (Class::*f)(BOOST_PP_ENUM_PARAMS(n, Param)))
|
||||||
{
|
{
|
||||||
return fun_helper(boost::function<Ret (Class* BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param))>(f));
|
return fun_helper(boost::function<Ret (Class* BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param))>(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a const class method of n parameters with name
|
* Register a const class method of n parameters with name
|
||||||
*/
|
*/
|
||||||
template<typename Ret, typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)>
|
template<typename Ret, typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)>
|
||||||
Proxy_Function fun_helper(Ret (Class::*f)(BOOST_PP_ENUM_PARAMS(n, Param))const)
|
Proxy_Function fun_helper(Ret (Class::*f)(BOOST_PP_ENUM_PARAMS(n, Param))const)
|
||||||
{
|
{
|
||||||
return fun_helper(boost::function<Ret (const Class* BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param))>(f));
|
return fun_helper(boost::function<Ret (const Class* BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param))>(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user