1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/detail/invoke.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,100 @@
1.4 +#if !defined(BOOST_PP_IS_ITERATING)
1.5 +
1.6 +// Copyright David Abrahams 2002.
1.7 +// Distributed under the Boost Software License, Version 1.0. (See
1.8 +// accompanying file LICENSE_1_0.txt or copy at
1.9 +// http://www.boost.org/LICENSE_1_0.txt)
1.10 +# ifndef INVOKE_DWA20021122_HPP
1.11 +# define INVOKE_DWA20021122_HPP
1.12 +
1.13 +# include <boost/python/detail/prefix.hpp>
1.14 +# include <boost/python/detail/preprocessor.hpp>
1.15 +# include <boost/python/detail/none.hpp>
1.16 +
1.17 +# include <boost/type_traits/is_member_function_pointer.hpp>
1.18 +
1.19 +# include <boost/preprocessor/iterate.hpp>
1.20 +# include <boost/preprocessor/facilities/intercept.hpp>
1.21 +# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
1.22 +# include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
1.23 +# include <boost/preprocessor/repetition/enum_binary_params.hpp>
1.24 +# include <boost/python/to_python_value.hpp>
1.25 +
1.26 +// This file declares a series of overloaded invoke(...) functions,
1.27 +// used to invoke wrapped C++ function (object)s from Python. Each one
1.28 +// accepts:
1.29 +//
1.30 +// - a tag which identifies the invocation syntax (e.g. member
1.31 +// functions must be invoked with a different syntax from regular
1.32 +// functions)
1.33 +//
1.34 +// - a pointer to a result converter type, used solely as a way of
1.35 +// transmitting the type of the result converter to the function (or
1.36 +// an int, if the return type is void).
1.37 +//
1.38 +// - the "function", which may be a function object, a function or
1.39 +// member function pointer, or a defaulted_virtual_fn.
1.40 +//
1.41 +// - The arg_from_python converters for each of the arguments to be
1.42 +// passed to the function being invoked.
1.43 +
1.44 +namespace boost { namespace python { namespace detail {
1.45 +
1.46 +// This "result converter" is really just used as a dispatch tag to
1.47 +// invoke(...), selecting the appropriate implementation
1.48 +typedef int void_result_to_python;
1.49 +
1.50 +template <bool void_return, bool member>
1.51 +struct invoke_tag_ {};
1.52 +
1.53 +// A metafunction returning the appropriate tag type for invoking an
1.54 +// object of type F with return type R.
1.55 +template <class R, class F>
1.56 +struct invoke_tag
1.57 + : invoke_tag_<
1.58 + is_same<R,void>::value
1.59 + , is_member_function_pointer<F>::value
1.60 + >
1.61 +{
1.62 +};
1.63 +
1.64 +# define BOOST_PP_ITERATION_PARAMS_1 \
1.65 + (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/invoke.hpp>))
1.66 +# include BOOST_PP_ITERATE()
1.67 +
1.68 +}}} // namespace boost::python::detail
1.69 +
1.70 +# endif // INVOKE_DWA20021122_HPP
1.71 +#else
1.72 +
1.73 +# define N BOOST_PP_ITERATION()
1.74 +
1.75 +template <class RC, class F BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)>
1.76 +inline PyObject* invoke(invoke_tag_<false,false>, RC const& rc, F& f BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) )
1.77 +{
1.78 + return rc(f( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT) ));
1.79 +}
1.80 +
1.81 +template <class RC, class F BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)>
1.82 +inline PyObject* invoke(invoke_tag_<true,false>, RC const&, F& f BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) )
1.83 +{
1.84 + f( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT) );
1.85 + return none();
1.86 +}
1.87 +
1.88 +template <class RC, class F, class TC BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)>
1.89 +inline PyObject* invoke(invoke_tag_<false,true>, RC const& rc, F& f, TC& tc BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) )
1.90 +{
1.91 + return rc( (tc().*f)(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT)) );
1.92 +}
1.93 +
1.94 +template <class RC, class F, class TC BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)>
1.95 +inline PyObject* invoke(invoke_tag_<true,true>, RC const&, F& f, TC& tc BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) )
1.96 +{
1.97 + (tc().*f)(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT));
1.98 + return none();
1.99 +}
1.100 +
1.101 +# undef N
1.102 +
1.103 +#endif // BOOST_PP_IS_ITERATING