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