Fix "bind_first" for non member functions
This commit is contained in:
parent
1568fedebd
commit
24e717d532
@ -26,6 +26,7 @@
|
|||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define n BOOST_PP_ITERATION()
|
# define n BOOST_PP_ITERATION()
|
||||||
|
# define m BOOST_PP_INC(n)
|
||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
@ -44,9 +45,9 @@ namespace chaiscript
|
|||||||
return boost::bind(f, o BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, param, ~));
|
return boost::bind(f, o BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, param, ~));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Ret,typename O BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) >
|
template<typename Ret,typename O BOOST_PP_COMMA_IF(m) BOOST_PP_ENUM_PARAMS(m, typename Param) >
|
||||||
boost::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param))>
|
boost::function<Ret (BOOST_PP_ENUM_PARAMS(m, Param))>
|
||||||
bind_first(Ret (*f)(BOOST_PP_ENUM_PARAMS(n, Param)), const O &o)
|
bind_first(Ret (*f)(BOOST_PP_ENUM_PARAMS(m, Param)), const O &o)
|
||||||
{
|
{
|
||||||
return boost::bind(f, o BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, param, ~));
|
return boost::bind(f, o BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, param, ~));
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,10 @@ void log(const std::string &module, const std::string &msg)
|
|||||||
std::cout << "[" << boost::posix_time::microsec_clock::local_time() << "] <" << module << "> " << msg << std::endl;
|
std::cout << "[" << boost::posix_time::microsec_clock::local_time() << "] <" << module << "> " << msg << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bound_log(const std::string &msg)
|
||||||
|
{
|
||||||
|
log(msg);
|
||||||
|
}
|
||||||
|
|
||||||
void hello_world(const chaiscript::Boxed_Value &o)
|
void hello_world(const chaiscript::Boxed_Value &o)
|
||||||
{
|
{
|
||||||
@ -148,6 +152,7 @@ int main(int argc, char *argv[]) {
|
|||||||
// Test ability to register a function that excepts a shared_ptr version of a type
|
// Test ability to register a function that excepts a shared_ptr version of a type
|
||||||
chai("take_shared_ptr(\"Hello World as a shared_ptr\");");
|
chai("take_shared_ptr(\"Hello World as a shared_ptr\");");
|
||||||
|
|
||||||
|
chai.add(bound_fun(&bound_log, std::string("Msg")), "BoundFun");
|
||||||
|
|
||||||
//Dynamic objects test
|
//Dynamic objects test
|
||||||
chai.add(chaiscript::Proxy_Function(new Dynamic_Object_Function("TestType", fun(&hello_world))), "hello_world");
|
chai.add(chaiscript::Proxy_Function(new Dynamic_Object_Function("TestType", fun(&hello_world))), "hello_world");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user