sl@0: #if !defined(BOOST_PP_IS_ITERATING) sl@0: sl@0: // Copyright David Abrahams 2002. sl@0: // Distributed under the Boost Software License, Version 1.0. (See sl@0: // accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: # ifndef CALL_DWA2002411_HPP sl@0: # define CALL_DWA2002411_HPP sl@0: sl@0: # include sl@0: sl@0: # include sl@0: sl@0: # include sl@0: # include 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: # include sl@0: sl@0: namespace boost { namespace python { 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, (0, 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: }} // namespace boost::python sl@0: sl@0: # endif // CALL_DWA2002411_HPP sl@0: sl@0: #elif BOOST_PP_ITERATION_DEPTH() == 1 sl@0: # if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \ sl@0: && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201))) sl@0: # line BOOST_PP_LINE(__LINE__, call.hpp) sl@0: # endif sl@0: sl@0: # define N BOOST_PP_ITERATION() sl@0: sl@0: template < sl@0: class R sl@0: BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A) sl@0: > sl@0: typename detail::returnable::type sl@0: call(PyObject* callable sl@0: BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a) sl@0: , boost::type* = 0 sl@0: ) sl@0: { sl@0: PyObject* const result = sl@0: PyEval_CallFunction( sl@0: callable 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: sl@0: // This conversion *must not* be done in the same expression as sl@0: // the call, because, in the special case where the result is a sl@0: // reference a Python object which was created by converting a C++ sl@0: // argument for passing to PyEval_CallFunction, its reference sl@0: // count will be 2 until the end of the full expression containing sl@0: // the conversion, and that interferes with dangling sl@0: // pointer/reference detection. sl@0: converter::return_from_python converter; sl@0: return converter(result); sl@0: } sl@0: sl@0: # undef N sl@0: sl@0: #endif