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: # ifndef INVOKE_DWA20021122_HPP sl@0: # define INVOKE_DWA20021122_HPP sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: 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: // This file declares a series of overloaded invoke(...) functions, sl@0: // used to invoke wrapped C++ function (object)s from Python. Each one sl@0: // accepts: sl@0: // sl@0: // - a tag which identifies the invocation syntax (e.g. member sl@0: // functions must be invoked with a different syntax from regular sl@0: // functions) sl@0: // sl@0: // - a pointer to a result converter type, used solely as a way of sl@0: // transmitting the type of the result converter to the function (or sl@0: // an int, if the return type is void). sl@0: // sl@0: // - the "function", which may be a function object, a function or sl@0: // member function pointer, or a defaulted_virtual_fn. sl@0: // sl@0: // - The arg_from_python converters for each of the arguments to be sl@0: // passed to the function being invoked. sl@0: sl@0: namespace boost { namespace python { namespace detail { sl@0: sl@0: // This "result converter" is really just used as a dispatch tag to sl@0: // invoke(...), selecting the appropriate implementation sl@0: typedef int void_result_to_python; sl@0: sl@0: template sl@0: struct invoke_tag_ {}; sl@0: sl@0: // A metafunction returning the appropriate tag type for invoking an sl@0: // object of type F with return type R. sl@0: template sl@0: struct invoke_tag sl@0: : invoke_tag_< sl@0: is_same::value sl@0: , is_member_function_pointer::value sl@0: > sl@0: { sl@0: }; sl@0: sl@0: # define BOOST_PP_ITERATION_PARAMS_1 \ sl@0: (3, (0, BOOST_PYTHON_MAX_ARITY, )) sl@0: # include BOOST_PP_ITERATE() sl@0: sl@0: }}} // namespace boost::python::detail sl@0: sl@0: # endif // INVOKE_DWA20021122_HPP sl@0: #else sl@0: sl@0: # define N BOOST_PP_ITERATION() sl@0: sl@0: template sl@0: inline PyObject* invoke(invoke_tag_, RC const& rc, F& f BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) ) sl@0: { sl@0: return rc(f( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT) )); sl@0: } sl@0: sl@0: template sl@0: inline PyObject* invoke(invoke_tag_, RC const&, F& f BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) ) sl@0: { sl@0: f( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT) ); sl@0: return none(); sl@0: } sl@0: sl@0: template sl@0: inline PyObject* invoke(invoke_tag_, RC const& rc, F& f, TC& tc BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) ) sl@0: { sl@0: return rc( (tc().*f)(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT)) ); sl@0: } sl@0: sl@0: template sl@0: inline PyObject* invoke(invoke_tag_, RC const&, F& f, TC& tc BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) ) sl@0: { sl@0: (tc().*f)(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT)); sl@0: return none(); sl@0: } sl@0: sl@0: # undef N sl@0: sl@0: #endif // BOOST_PP_IS_ITERATING