// This file is distributed under the BSD License. // See "license.txt" for details. // Copyright 2009-2010, Jonathan Turner (jonathan@emptycrate.com) // and Jason Turner (jason@emptycrate.com) // http://www.chaiscript.com #ifndef __register_function_hpp__ #define __register_function_hpp__ #include "dispatchkit.hpp" #include "bind_first.hpp" #include #include #include #include #include #include namespace chaiscript { namespace detail { template struct Fun_Helper { template static Proxy_Function go(T t) { return Proxy_Function( new Proxy_Function_Impl< typename boost::function_types::function_type >::type> ( boost::function< typename boost::function_types::function_type >::type >(t))); } }; template<> struct Fun_Helper { template static Proxy_Function go(T t) { return Proxy_Function( new Proxy_Function_Impl< typename boost::function_types::function_type >::type> ( boost::function< typename boost::function_types::function_type >::type >(boost::mem_fn(t)))); } }; template<> struct Fun_Helper { template static Proxy_Function go(T Class::* m) { return Proxy_Function(new Attribute_Access(m)); } }; } template Proxy_Function fun(const boost::function &f) { return Proxy_Function(new Proxy_Function_Impl(f)); } template Proxy_Function fun(T t) { return detail::Fun_Helper::value, boost::function_types::is_member_function_pointer::value>::go(t); } template Proxy_Function fun(T t, const Q &q) { return fun(detail::bind_first(t, q)); } template Proxy_Function fun(T t, const Q &q, const R &r) { return fun(detail::bind_first(detail::bind_first(t, q), r)); } } #endif