Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/python/call.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #if !defined(BOOST_PP_IS_ITERATING)
0002 
0003 // Copyright David Abrahams 2002.
0004 // Distributed under the Boost Software License, Version 1.0. (See
0005 // accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 # ifndef CALL_DWA2002411_HPP
0009 #  define CALL_DWA2002411_HPP
0010 
0011 # include <boost/python/detail/prefix.hpp>
0012 
0013 #  include <boost/type.hpp>
0014 
0015 #  include <boost/python/converter/arg_to_python.hpp>
0016 #  include <boost/python/converter/return_from_python.hpp>
0017 #  include <boost/python/detail/preprocessor.hpp>
0018 #  include <boost/python/detail/void_return.hpp>
0019 
0020 #  include <boost/preprocessor/comma_if.hpp>
0021 #  include <boost/preprocessor/iterate.hpp>
0022 #  include <boost/preprocessor/repeat.hpp>
0023 #  include <boost/preprocessor/debug/line.hpp>
0024 #  include <boost/preprocessor/repetition/enum_trailing_params.hpp>
0025 #  include <boost/preprocessor/repetition/enum_binary_params.hpp>
0026 
0027 namespace boost { namespace python {
0028 
0029 # define BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET(z, n, _) \
0030     , converter::arg_to_python<A##n>(a##n).get()
0031 
0032 #  define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/call.hpp>))
0033 #  include BOOST_PP_ITERATE()
0034 
0035 #  undef BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET
0036 
0037 }} // namespace boost::python
0038 
0039 # endif // CALL_DWA2002411_HPP
0040 
0041 // For gcc 4.4 compatability, we must include the
0042 // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
0043 #else // BOOST_PP_IS_ITERATING
0044 #if BOOST_PP_ITERATION_DEPTH() == 1
0045 # if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100)                      \
0046         && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
0047 #  line BOOST_PP_LINE(__LINE__, call.hpp)
0048 # endif
0049 
0050 # define N BOOST_PP_ITERATION()
0051 
0052 template <
0053     class R
0054     BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)
0055     >
0056 typename detail::returnable<R>::type
0057 call(PyObject* callable
0058     BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a)
0059     , boost::type<R>* = 0
0060     )
0061 {
0062     PyObject* const result = 
0063         PyObject_CallFunction(
0064             callable
0065             , const_cast<char*>("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")")
0066             BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
0067             );
0068     
0069     // This conversion *must not* be done in the same expression as
0070     // the call, because, in the special case where the result is a
0071     // reference a Python object which was created by converting a C++
0072     // argument for passing to PyObject_CallFunction, its reference
0073     // count will be 2 until the end of the full expression containing
0074     // the conversion, and that interferes with dangling
0075     // pointer/reference detection.
0076     converter::return_from_python<R> converter;
0077     return converter(result);
0078 }
0079 
0080 # undef N
0081 
0082 #endif // BOOST_PP_ITERATION_DEPTH()
0083 #endif