Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:38

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 # ifndef INVOKE_DWA20021122_HPP
0008 #  define INVOKE_DWA20021122_HPP
0009 
0010 #  include <boost/python/detail/prefix.hpp>
0011 #  include <boost/python/detail/preprocessor.hpp>
0012 #  include <boost/python/detail/none.hpp>
0013 
0014 #  include <boost/preprocessor/iterate.hpp>
0015 #  include <boost/preprocessor/facilities/intercept.hpp>
0016 #  include <boost/preprocessor/repetition/enum_trailing_params.hpp>
0017 #  include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
0018 #  include <boost/preprocessor/repetition/enum_binary_params.hpp>
0019 #  include <boost/python/to_python_value.hpp>
0020 
0021 // This file declares a series of overloaded invoke(...)  functions,
0022 // used to invoke wrapped C++ function (object)s from Python. Each one
0023 // accepts:
0024 //
0025 //   - a tag which identifies the invocation syntax (e.g. member
0026 //   functions must be invoked with a different syntax from regular
0027 //   functions)
0028 //
0029 //   - a pointer to a result converter type, used solely as a way of
0030 //   transmitting the type of the result converter to the function (or
0031 //   an int, if the return type is void).
0032 //
0033 //   - the "function", which may be a function object, a function or
0034 //   member function pointer, or a defaulted_virtual_fn.
0035 //
0036 //   - The arg_from_python converters for each of the arguments to be
0037 //   passed to the function being invoked.
0038 
0039 namespace boost { namespace python { namespace detail { 
0040 
0041 // This "result converter" is really just used as a dispatch tag to
0042 // invoke(...), selecting the appropriate implementation
0043 typedef int void_result_to_python;
0044 
0045 template <bool void_return, bool member>
0046 struct invoke_tag_ {};
0047 
0048 // A metafunction returning the appropriate tag type for invoking an
0049 // object of type F with return type R.
0050 template <class R, class F>
0051 struct invoke_tag
0052   : invoke_tag_<
0053         is_same<R,void>::value
0054       , is_member_function_pointer<F>::value
0055     >
0056 {
0057 };
0058 
0059 #  define BOOST_PP_ITERATION_PARAMS_1                                            \
0060         (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/invoke.hpp>))
0061 #  include BOOST_PP_ITERATE()
0062 
0063 }}} // namespace boost::python::detail
0064 
0065 # endif // INVOKE_DWA20021122_HPP
0066 #else 
0067 
0068 # define N BOOST_PP_ITERATION()
0069 
0070 template <class RC, class F BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)>
0071 inline PyObject* invoke(invoke_tag_<false,false>, RC const& rc, F& f BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) )
0072 {
0073     return rc(f( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT) ));
0074 }
0075                  
0076 template <class RC, class F BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)>
0077 inline PyObject* invoke(invoke_tag_<true,false>, RC const&, F& f BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) )
0078 {
0079     f( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT) );
0080     return none();
0081 }
0082 
0083 template <class RC, class F, class TC BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)>
0084 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) )
0085 {
0086     return rc( (tc().*f)(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT)) );
0087 }
0088                  
0089 template <class RC, class F, class TC BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)>
0090 inline PyObject* invoke(invoke_tag_<true,true>, RC const&, F& f, TC& tc BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) )
0091 {
0092     (tc().*f)(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT));
0093     return none();
0094 }
0095 
0096 # undef N
0097 
0098 #endif // BOOST_PP_IS_ITERATING