Chris@16: // Copyright David Abrahams 2002. Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: #ifndef DEFAULT_CALL_POLICIES_DWA2002131_HPP Chris@16: # define DEFAULT_CALL_POLICIES_DWA2002131_HPP Chris@16: Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: # include Chris@16: Chris@16: namespace boost { namespace python { Chris@16: Chris@16: template struct to_python_value; Chris@16: Chris@16: namespace detail Chris@16: { Chris@16: // for "readable" error messages Chris@16: template struct specify_a_return_value_policy_to_wrap_functions_returning Chris@16: # if defined(__GNUC__) && __GNUC__ >= 3 || defined(__EDG__) Chris@16: {} Chris@16: # endif Chris@16: ; Chris@16: } Chris@16: Chris@16: struct default_result_converter; Chris@16: Chris@16: struct default_call_policies Chris@16: { Chris@16: // Ownership of this argument tuple will ultimately be adopted by Chris@16: // the caller. Chris@16: template Chris@16: static bool precall(ArgumentPackage const&) Chris@16: { Chris@16: return true; Chris@16: } Chris@16: Chris@16: // Pass the result through Chris@16: template Chris@16: static PyObject* postcall(ArgumentPackage const&, PyObject* result) Chris@16: { Chris@16: return result; Chris@16: } Chris@16: Chris@16: typedef default_result_converter result_converter; Chris@16: typedef PyObject* argument_package; Chris@16: Chris@16: template Chris@16: struct extract_return_type : mpl::front Chris@16: { Chris@16: }; Chris@16: Chris@16: }; Chris@16: Chris@16: struct default_result_converter Chris@16: { Chris@16: template Chris@16: struct apply Chris@16: { Chris@16: typedef typename mpl::if_< Chris@16: mpl::or_, is_reference > Chris@16: , detail::specify_a_return_value_policy_to_wrap_functions_returning Chris@16: , boost::python::to_python_value< Chris@16: typename detail::value_arg::type Chris@16: > Chris@16: >::type type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: // Exceptions for c strings an PyObject*s Chris@16: template <> Chris@16: struct default_result_converter::apply Chris@16: { Chris@16: typedef boost::python::to_python_value type; Chris@16: }; Chris@16: Chris@16: template <> Chris@16: struct default_result_converter::apply Chris@16: { Chris@16: typedef boost::python::to_python_value type; Chris@16: }; Chris@16: Chris@16: }} // namespace boost::python Chris@16: Chris@16: #endif // DEFAULT_CALL_POLICIES_DWA2002131_HPP