Warning, file /include/boost/python/return_arg.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #ifndef RETURN_ARG_DWA2003719_HPP
0006 # define RETURN_ARG_DWA2003719_HPP
0007 # include <boost/python/default_call_policies.hpp>
0008 # include <boost/python/detail/none.hpp>
0009 # include <boost/python/detail/value_arg.hpp>
0010
0011 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
0012 # include <boost/python/converter/pytype_function.hpp>
0013 #endif
0014
0015 # include <boost/python/detail/type_traits.hpp>
0016
0017 # include <boost/mpl/int.hpp>
0018 # include <boost/mpl/at.hpp>
0019
0020 # include <boost/static_assert.hpp>
0021 # include <boost/python/refcount.hpp>
0022
0023 # include <cstddef>
0024
0025 namespace boost { namespace python {
0026
0027 namespace detail
0028 {
0029 template <std::size_t>
0030 struct return_arg_pos_argument_must_be_positive
0031 # if defined(__GNUC__) || defined(__EDG__)
0032 {}
0033 # endif
0034 ;
0035
0036 struct return_none
0037 {
0038 template <class T> struct apply
0039 {
0040 struct type
0041 {
0042 static bool convertible()
0043 {
0044 return true;
0045 }
0046
0047 PyObject *operator()( typename value_arg<T>::type ) const
0048 {
0049 return none();
0050 }
0051 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
0052 PyTypeObject const *get_pytype() const { return converter::expected_pytype_for_arg<T>::get_pytype() ; }
0053 #endif
0054 };
0055 };
0056 };
0057 }
0058
0059 template <
0060 std::size_t arg_pos=1
0061 , class Base = default_call_policies
0062 >
0063 struct return_arg : Base
0064 {
0065 private:
0066 BOOST_STATIC_CONSTANT(bool, legal = arg_pos > 0);
0067
0068 public:
0069 typedef typename mpl::if_c<
0070 legal
0071 , detail::return_none
0072 , detail::return_arg_pos_argument_must_be_positive<arg_pos>
0073
0074
0075
0076
0077 >::type result_converter;
0078
0079 template <class ArgumentPackage>
0080 static PyObject* postcall(ArgumentPackage const& args, PyObject* result)
0081 {
0082
0083
0084 BOOST_STATIC_ASSERT(arg_pos > 0);
0085
0086 result = Base::postcall(args,result);
0087 if (!result)
0088 return 0;
0089 Py_DECREF(result);
0090 return incref( detail::get(mpl::int_<arg_pos-1>(),args) );
0091 }
0092
0093 template <class Sig>
0094 struct extract_return_type : mpl::at_c<Sig, arg_pos>
0095 {
0096 };
0097
0098 };
0099
0100 template <
0101 class Base = default_call_policies
0102 >
0103 struct return_self
0104 : return_arg<1,Base>
0105 {};
0106
0107 }}
0108
0109 #endif