sl@0: #if !defined(BOOST_PP_IS_ITERATING) sl@0: sl@0: // Copyright David Abrahams 2004. Distributed under the Boost sl@0: // Software License, Version 1.0. (See accompanying sl@0: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) sl@0: #ifndef OVERRIDE_DWA2004721_HPP sl@0: # define OVERRIDE_DWA2004721_HPP sl@0: sl@0: # include sl@0: sl@0: # include sl@0: sl@0: # include sl@0: # include sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: # include sl@0: sl@0: namespace boost { namespace python { sl@0: sl@0: class override; sl@0: sl@0: namespace detail sl@0: { sl@0: class wrapper_base; sl@0: sl@0: // The result of calling a method. sl@0: class method_result sl@0: { sl@0: private: sl@0: friend class boost::python::override; sl@0: explicit method_result(PyObject* x) sl@0: : m_obj(x) sl@0: {} sl@0: sl@0: public: sl@0: template sl@0: operator T() sl@0: { sl@0: converter::return_from_python converter; sl@0: return converter(m_obj.release()); sl@0: } sl@0: sl@0: # if BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(140050215)) sl@0: template sl@0: operator T*() sl@0: { sl@0: converter::return_from_python converter; sl@0: return converter(m_obj.release()); sl@0: } sl@0: # endif sl@0: sl@0: # if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) || BOOST_WORKAROUND(BOOST_INTEL_WIN, >= 900) sl@0: // No operator T& sl@0: # else sl@0: sl@0: template sl@0: operator T&() const sl@0: { sl@0: converter::return_from_python converter; sl@0: return converter(const_cast&>(m_obj).release()); sl@0: } sl@0: # endif sl@0: sl@0: template sl@0: T as(type* = 0) sl@0: { sl@0: converter::return_from_python converter; sl@0: return converter(m_obj.release()); sl@0: } sl@0: sl@0: template sl@0: T unchecked(type* = 0) sl@0: { sl@0: return extract(m_obj)(); sl@0: } sl@0: private: sl@0: mutable handle<> m_obj; sl@0: }; sl@0: } sl@0: sl@0: class override : public object sl@0: { sl@0: private: sl@0: friend class detail::wrapper_base; sl@0: override(handle<> x) sl@0: : object(x) sl@0: {} sl@0: sl@0: public: sl@0: detail::method_result sl@0: operator()() const sl@0: { sl@0: detail::method_result x( sl@0: PyEval_CallFunction( sl@0: this->ptr() sl@0: , const_cast("()") sl@0: )); sl@0: return x; sl@0: } sl@0: sl@0: # define BOOST_PYTHON_fast_arg_to_python_get(z, n, _) \ sl@0: , converter::arg_to_python(a##n).get() sl@0: sl@0: # define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PYTHON_MAX_ARITY, )) sl@0: # include BOOST_PP_ITERATE() sl@0: sl@0: # undef BOOST_PYTHON_fast_arg_to_python_get sl@0: }; sl@0: sl@0: }} // namespace boost::python sl@0: sl@0: #endif // OVERRIDE_DWA2004721_HPP sl@0: sl@0: #else sl@0: # if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \ sl@0: && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201))) sl@0: # line BOOST_PP_LINE(__LINE__, override.hpp) sl@0: # endif sl@0: sl@0: # define N BOOST_PP_ITERATION() sl@0: sl@0: template < sl@0: BOOST_PP_ENUM_PARAMS_Z(1, N, class A) sl@0: > sl@0: detail::method_result sl@0: operator()( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a) ) const sl@0: { sl@0: detail::method_result x( sl@0: PyEval_CallFunction( sl@0: this->ptr() sl@0: , const_cast("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")") sl@0: BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_fast_arg_to_python_get, nil) sl@0: )); sl@0: return x; sl@0: } sl@0: sl@0: # undef N sl@0: #endif