Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:07:42

0001 // Copyright David Abrahams 2002.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef FUNCTION_HANDLE_DWA2002725_HPP
0006 # define FUNCTION_HANDLE_DWA2002725_HPP
0007 # include <boost/python/handle.hpp>
0008 # include <boost/python/detail/caller.hpp>
0009 # include <boost/python/default_call_policies.hpp>
0010 # include <boost/python/object/py_function.hpp>
0011 # include <boost/python/signature.hpp>
0012 
0013 namespace boost { namespace python { namespace objects { 
0014 
0015 BOOST_PYTHON_DECL handle<> function_handle_impl(py_function const& f);
0016 
0017 // Just like function_object, but returns a handle<> instead. Using
0018 // this for arg_to_python<> allows us to break a circular dependency
0019 // between object and arg_to_python.
0020 template <class F, class Signature>
0021 inline handle<> function_handle(F const& f, Signature)
0022 {
0023     enum { n_arguments = mpl::size<Signature>::value - 1 };
0024 
0025     return objects::function_handle_impl(
0026         python::detail::caller<
0027             F,default_call_policies,Signature
0028         >(
0029             f, default_call_policies()
0030          )
0031     );
0032 }
0033 
0034 // Just like make_function, but returns a handle<> intead. Same
0035 // reasoning as above.
0036 template <class F>
0037 handle<> make_function_handle(F f)
0038 {
0039     return objects::function_handle(f, python::detail::get_signature(f));
0040 }
0041 
0042 }}} // namespace boost::python::objects
0043 
0044 #endif // FUNCTION_HANDLE_DWA2002725_HPP