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 DEFAULT_CALL_POLICIES_DWA2002131_HPP
6 # define DEFAULT_CALL_POLICIES_DWA2002131_HPP
8 # include <boost/python/detail/prefix.hpp>
9 # include <boost/mpl/if.hpp>
10 # include <boost/python/to_python_value.hpp>
11 # include <boost/python/detail/value_arg.hpp>
12 # include <boost/type_traits/transform_traits.hpp>
13 # include <boost/type_traits/is_pointer.hpp>
14 # include <boost/type_traits/is_reference.hpp>
15 # include <boost/mpl/or.hpp>
16 # include <boost/mpl/front.hpp>
18 namespace boost { namespace python {
20 template <class T> struct to_python_value;
24 // for "readable" error messages
25 template <class T> struct specify_a_return_value_policy_to_wrap_functions_returning
26 # if defined(__GNUC__) || defined(__EDG__)
32 struct default_result_converter;
34 struct default_call_policies
36 // Ownership of this argument tuple will ultimately be adopted by
38 template <class ArgumentPackage>
39 static bool precall(ArgumentPackage const&)
44 // Pass the result through
45 template <class ArgumentPackage>
46 static PyObject* postcall(ArgumentPackage const&, PyObject* result)
51 typedef default_result_converter result_converter;
52 typedef PyObject* argument_package;
55 struct extract_return_type : mpl::front<Sig>
61 struct default_result_converter
66 typedef typename mpl::if_<
67 mpl::or_<is_pointer<R>, is_reference<R> >
68 , detail::specify_a_return_value_policy_to_wrap_functions_returning<R>
69 , boost::python::to_python_value<
70 typename detail::value_arg<R>::type
76 // Exceptions for c strings an PyObject*s
78 struct default_result_converter::apply<char const*>
80 typedef boost::python::to_python_value<char const*const&> type;
84 struct default_result_converter::apply<PyObject*>
86 typedef boost::python::to_python_value<PyObject*const&> type;
89 }} // namespace boost::python
91 #endif // DEFAULT_CALL_POLICIES_DWA2002131_HPP