// 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 #ifndef __register_function_hpp__ #define __register_function_hpp__ #include "dispatchkit.hpp" #include "bind_first.hpp" #include #include #include #include namespace chaiscript { namespace detail { /** * Helper function for register_member function */ template T &get_member(T Class::* m, Class *obj) { return (obj->*m); } template boost::function mk_boost_fun(const boost::function &f) { return f; } template boost::function< typename boost::function_types::function_type >::type > mk_boost_fun(T t) { return boost::function< typename boost::function_types::function_type >::type >(t); } template Proxy_Function fun_helper(T Class::* m) { return fun_helper(boost::function(boost::bind(&detail::get_member, m, _1))); } template Proxy_Function fun_helper(const boost::function &f) { return Proxy_Function(new Proxy_Function_Impl(f)); } } template Proxy_Function fun(const boost::function &f) { return detail::fun_helper(f); } template Proxy_Function fun(T t) { return detail::fun_helper(detail::mk_boost_fun(t)); } template Proxy_Function fun(T t, const Q &q) { return detail::fun_helper(bind_first(t, q)); } template Proxy_Function fun(T t, const Q &q, const R &r) { return detail::fun_helper(bind_first(bind_first(t, q), r)); } } #endif