Chris@16
|
1 // Copyright David Abrahams 2002.
|
Chris@16
|
2 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
3 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
4 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5 #ifndef FUNCTION_HANDLE_DWA2002725_HPP
|
Chris@16
|
6 # define FUNCTION_HANDLE_DWA2002725_HPP
|
Chris@16
|
7 # include <boost/python/handle.hpp>
|
Chris@16
|
8 # include <boost/python/detail/caller.hpp>
|
Chris@16
|
9 # include <boost/python/default_call_policies.hpp>
|
Chris@16
|
10 # include <boost/python/object/py_function.hpp>
|
Chris@16
|
11 # include <boost/python/signature.hpp>
|
Chris@16
|
12
|
Chris@16
|
13 namespace boost { namespace python { namespace objects {
|
Chris@16
|
14
|
Chris@16
|
15 BOOST_PYTHON_DECL handle<> function_handle_impl(py_function const& f);
|
Chris@16
|
16
|
Chris@16
|
17 // Just like function_object, but returns a handle<> instead. Using
|
Chris@16
|
18 // this for arg_to_python<> allows us to break a circular dependency
|
Chris@16
|
19 // between object and arg_to_python.
|
Chris@16
|
20 template <class F, class Signature>
|
Chris@16
|
21 inline handle<> function_handle(F const& f, Signature)
|
Chris@16
|
22 {
|
Chris@16
|
23 enum { n_arguments = mpl::size<Signature>::value - 1 };
|
Chris@16
|
24
|
Chris@16
|
25 return objects::function_handle_impl(
|
Chris@16
|
26 python::detail::caller<
|
Chris@16
|
27 F,default_call_policies,Signature
|
Chris@16
|
28 >(
|
Chris@16
|
29 f, default_call_policies()
|
Chris@16
|
30 )
|
Chris@16
|
31 );
|
Chris@16
|
32 }
|
Chris@16
|
33
|
Chris@16
|
34 // Just like make_function, but returns a handle<> intead. Same
|
Chris@16
|
35 // reasoning as above.
|
Chris@16
|
36 template <class F>
|
Chris@16
|
37 handle<> make_function_handle(F f)
|
Chris@16
|
38 {
|
Chris@16
|
39 return objects::function_handle(f, python::detail::get_signature(f));
|
Chris@16
|
40 }
|
Chris@16
|
41
|
Chris@16
|
42 }}} // namespace boost::python::objects
|
Chris@16
|
43
|
Chris@16
|
44 #endif // FUNCTION_HANDLE_DWA2002725_HPP
|