Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:40

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 DEFAULT_CALL_POLICIES_DWA2002131_HPP
0006 # define DEFAULT_CALL_POLICIES_DWA2002131_HPP
0007 
0008 # include <boost/python/detail/prefix.hpp>
0009 # include <boost/mpl/if.hpp>
0010 # include <boost/python/to_python_value.hpp>
0011 # include <boost/python/detail/type_traits.hpp>
0012 # include <boost/python/detail/value_arg.hpp>
0013 # include <boost/mpl/or.hpp>
0014 # include <boost/mpl/front.hpp>
0015 
0016 namespace boost { namespace python { 
0017 
0018 template <class T> struct to_python_value;
0019 
0020 namespace detail
0021 {
0022 // for "readable" error messages
0023   template <class T> struct specify_a_return_value_policy_to_wrap_functions_returning
0024 # if defined(__GNUC__) || defined(__EDG__)
0025   {}
0026 # endif 
0027   ;
0028 }
0029 
0030 struct default_result_converter;
0031 
0032 struct default_call_policies
0033 {
0034     // Ownership of this argument tuple will ultimately be adopted by
0035     // the caller.
0036     template <class ArgumentPackage>
0037     static bool precall(ArgumentPackage const&)
0038     {
0039         return true;
0040     }
0041 
0042     // Pass the result through
0043     template <class ArgumentPackage>
0044     static PyObject* postcall(ArgumentPackage const&, PyObject* result)
0045     {
0046         return result;
0047     }
0048 
0049     typedef default_result_converter result_converter;
0050     typedef PyObject* argument_package;
0051 
0052     template <class Sig> 
0053     struct extract_return_type : mpl::front<Sig>
0054     {
0055     };
0056 
0057 };
0058 
0059 struct default_result_converter
0060 {
0061     template <class R>
0062     struct apply
0063     {
0064         typedef typename mpl::if_<
0065             mpl::or_<detail::is_pointer<R>, detail::is_reference<R> >
0066           , detail::specify_a_return_value_policy_to_wrap_functions_returning<R>
0067           , boost::python::to_python_value<
0068                 typename detail::value_arg<R>::type
0069             >
0070         >::type type;
0071     };
0072 };
0073 
0074 // Exceptions for c strings an PyObject*s
0075 template <>
0076 struct default_result_converter::apply<char const*>
0077 {
0078     typedef boost::python::to_python_value<char const*const&> type;
0079 };
0080 
0081 template <>
0082 struct default_result_converter::apply<PyObject*>
0083 {
0084     typedef boost::python::to_python_value<PyObject*const&> type;
0085 };
0086 
0087 }} // namespace boost::python
0088 
0089 #endif // DEFAULT_CALL_POLICIES_DWA2002131_HPP