Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:46:10

0001 #if !defined(BOOST_PP_IS_ITERATING)
0002 
0003 // Copyright David Abrahams 2004. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 #ifndef OVERRIDE_DWA2004721_HPP
0007 # define OVERRIDE_DWA2004721_HPP
0008 
0009 # include <boost/python/detail/prefix.hpp>
0010 
0011 # include <boost/python/converter/return_from_python.hpp>
0012 
0013 # include <boost/python/extract.hpp>
0014 # include <boost/python/handle.hpp>
0015 
0016 #  include <boost/preprocessor/iterate.hpp>
0017 #  include <boost/preprocessor/repeat.hpp>
0018 #  include <boost/preprocessor/debug/line.hpp>
0019 #  include <boost/preprocessor/repetition/enum_params.hpp>
0020 #  include <boost/preprocessor/repetition/enum_binary_params.hpp>
0021 
0022 #  include <boost/type.hpp>
0023 
0024 namespace boost { namespace python {
0025 
0026 class override;
0027 
0028 namespace detail
0029 {
0030   class wrapper_base;
0031   
0032   // The result of calling a method.
0033   class method_result
0034   {
0035    private:
0036       friend class boost::python::override;
0037       explicit method_result(PyObject* x)
0038         : m_obj(x)
0039       {}
0040 
0041    public:
0042       template <class T>
0043       operator T()
0044       {
0045           converter::return_from_python<T> converter;
0046           return converter(m_obj.release());
0047       }
0048 
0049 #  if BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(140050215))
0050       template <class T>
0051       operator T*()
0052       {
0053           converter::return_from_python<T*> converter;
0054           return converter(m_obj.release());
0055       }
0056 #  endif 
0057       
0058 #  if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) || BOOST_WORKAROUND(BOOST_INTEL_WIN, >= 900)
0059       // No operator T&
0060 #  else
0061       
0062       template <class T>
0063       operator T&() const
0064       {
0065           converter::return_from_python<T&> converter;
0066           return converter(const_cast<handle<>&>(m_obj).release());
0067       }
0068 #  endif 
0069 
0070       template <class T>
0071       T as(type<T>* = 0)
0072       {
0073           converter::return_from_python<T> converter;
0074           return converter(m_obj.release());
0075       }
0076 
0077       template <class T>
0078       T unchecked(type<T>* = 0)
0079       {
0080           return extract<T>(m_obj.get())();
0081       }
0082    private:
0083       mutable handle<> m_obj;
0084   };
0085 }
0086 
0087 class override : public object
0088 {
0089  private:
0090     friend class detail::wrapper_base;
0091     override(handle<> x)
0092       : object(x)
0093     {}
0094     
0095  public:
0096     detail::method_result
0097     operator()() const
0098     {
0099         detail::method_result x(
0100             PyObject_CallFunction(
0101                 this->ptr()
0102               , const_cast<char*>("()")
0103             ));
0104         return x;
0105     }
0106 
0107 # define BOOST_PYTHON_fast_arg_to_python_get(z, n, _)   \
0108     , converter::arg_to_python<A##n>(a##n).get()
0109 
0110 # define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PYTHON_MAX_ARITY, <boost/python/override.hpp>))
0111 # include BOOST_PP_ITERATE()
0112 
0113 # undef BOOST_PYTHON_fast_arg_to_python_get
0114 };
0115 
0116 }} // namespace boost::python
0117 
0118 #endif // OVERRIDE_DWA2004721_HPP
0119 
0120 #else
0121 # if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100)                      \
0122         && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
0123 #  line BOOST_PP_LINE(__LINE__, override.hpp)
0124 # endif 
0125 
0126 # define N BOOST_PP_ITERATION()
0127 
0128 template <
0129     BOOST_PP_ENUM_PARAMS_Z(1, N, class A)
0130     >
0131 detail::method_result
0132 operator()( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a) ) const
0133 {
0134     detail::method_result x(
0135         PyObject_CallFunction(
0136             this->ptr()
0137           , const_cast<char*>("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")")
0138             BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_fast_arg_to_python_get, nil)
0139         ));
0140     return x;
0141 }
0142 
0143 # undef N
0144 #endif