sl@0
|
1 |
#if !defined(BOOST_PP_IS_ITERATING)
|
sl@0
|
2 |
|
sl@0
|
3 |
// Copyright David Abrahams 2002.
|
sl@0
|
4 |
// Distributed under the Boost Software License, Version 1.0. (See
|
sl@0
|
5 |
// accompanying file LICENSE_1_0.txt or copy at
|
sl@0
|
6 |
// http://www.boost.org/LICENSE_1_0.txt)
|
sl@0
|
7 |
|
sl@0
|
8 |
# ifndef RESULT_DWA2002521_HPP
|
sl@0
|
9 |
# define RESULT_DWA2002521_HPP
|
sl@0
|
10 |
|
sl@0
|
11 |
# include <boost/type.hpp>
|
sl@0
|
12 |
|
sl@0
|
13 |
# include <boost/python/detail/preprocessor.hpp>
|
sl@0
|
14 |
|
sl@0
|
15 |
# include <boost/type_traits/object_traits.hpp>
|
sl@0
|
16 |
# include <boost/mpl/if.hpp>
|
sl@0
|
17 |
|
sl@0
|
18 |
# include <boost/preprocessor/comma_if.hpp>
|
sl@0
|
19 |
# include <boost/preprocessor/iterate.hpp>
|
sl@0
|
20 |
# include <boost/preprocessor/debug/line.hpp>
|
sl@0
|
21 |
# include <boost/preprocessor/enum_params.hpp>
|
sl@0
|
22 |
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
sl@0
|
23 |
|
sl@0
|
24 |
namespace boost { namespace python { namespace detail {
|
sl@0
|
25 |
|
sl@0
|
26 |
// Defines a family of overloaded function which, given x, a function
|
sl@0
|
27 |
// pointer, member [function] pointer, or an AdaptableFunction object,
|
sl@0
|
28 |
// returns a pointer to type<R>*, where R is the result type of
|
sl@0
|
29 |
// invoking the result of bind(x).
|
sl@0
|
30 |
//
|
sl@0
|
31 |
// In order to work around bugs in deficient compilers, if x might be
|
sl@0
|
32 |
// an AdaptableFunction object, you must pass OL as a second argument
|
sl@0
|
33 |
// to get this to work portably.
|
sl@0
|
34 |
|
sl@0
|
35 |
# define BOOST_PP_ITERATION_PARAMS_1 \
|
sl@0
|
36 |
(4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/result.hpp>, BOOST_PYTHON_FUNCTION_POINTER))
|
sl@0
|
37 |
# include BOOST_PP_ITERATE()
|
sl@0
|
38 |
|
sl@0
|
39 |
# define BOOST_PP_ITERATION_PARAMS_1 \
|
sl@0
|
40 |
(4, (0, BOOST_PYTHON_CV_COUNT - 1, <boost/python/detail/result.hpp>, BOOST_PYTHON_POINTER_TO_MEMBER))
|
sl@0
|
41 |
# include BOOST_PP_ITERATE()
|
sl@0
|
42 |
|
sl@0
|
43 |
template <class R, class T>
|
sl@0
|
44 |
boost::type<R>* result(R (T::*), int = 0) { return 0; }
|
sl@0
|
45 |
|
sl@0
|
46 |
# if (defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140) \
|
sl@0
|
47 |
|| (defined(__GNUC__) && __GNUC__ < 3) \
|
sl@0
|
48 |
|| (defined(__MWERKS__) && __MWERKS__ < 0x3000)
|
sl@0
|
49 |
// This code actually works on all implementations, but why use it when we don't have to?
|
sl@0
|
50 |
template <class T>
|
sl@0
|
51 |
struct get_result_type
|
sl@0
|
52 |
{
|
sl@0
|
53 |
typedef boost::type<typename T::result_type> type;
|
sl@0
|
54 |
};
|
sl@0
|
55 |
|
sl@0
|
56 |
struct void_type
|
sl@0
|
57 |
{
|
sl@0
|
58 |
typedef void type;
|
sl@0
|
59 |
};
|
sl@0
|
60 |
|
sl@0
|
61 |
template <class T>
|
sl@0
|
62 |
struct result_result
|
sl@0
|
63 |
{
|
sl@0
|
64 |
typedef typename mpl::if_c<
|
sl@0
|
65 |
is_class<T>::value
|
sl@0
|
66 |
, get_result_type<T>
|
sl@0
|
67 |
, void_type
|
sl@0
|
68 |
>::type t1;
|
sl@0
|
69 |
|
sl@0
|
70 |
typedef typename t1::type* type;
|
sl@0
|
71 |
};
|
sl@0
|
72 |
|
sl@0
|
73 |
template <class X>
|
sl@0
|
74 |
typename result_result<X>::type
|
sl@0
|
75 |
result(X const&, short) { return 0; }
|
sl@0
|
76 |
|
sl@0
|
77 |
# else // Simpler code for more-capable compilers
|
sl@0
|
78 |
template <class X>
|
sl@0
|
79 |
boost::type<typename X::result_type>*
|
sl@0
|
80 |
result(X const&, short = 0) { return 0; }
|
sl@0
|
81 |
|
sl@0
|
82 |
# endif
|
sl@0
|
83 |
|
sl@0
|
84 |
}}} // namespace boost::python::detail
|
sl@0
|
85 |
|
sl@0
|
86 |
# endif // RESULT_DWA2002521_HPP
|
sl@0
|
87 |
|
sl@0
|
88 |
/* --------------- function pointers --------------- */
|
sl@0
|
89 |
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
|
sl@0
|
90 |
# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
|
sl@0
|
91 |
&& BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
|
sl@0
|
92 |
# line BOOST_PP_LINE(__LINE__, result.hpp(function pointers))
|
sl@0
|
93 |
# endif
|
sl@0
|
94 |
|
sl@0
|
95 |
# define N BOOST_PP_ITERATION()
|
sl@0
|
96 |
|
sl@0
|
97 |
template <class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
|
sl@0
|
98 |
boost::type<R>* result(R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)), int = 0)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
return 0;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
# undef N
|
sl@0
|
104 |
|
sl@0
|
105 |
/* --------------- pointers-to-members --------------- */
|
sl@0
|
106 |
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
|
sl@0
|
107 |
// Outer over cv-qualifiers
|
sl@0
|
108 |
|
sl@0
|
109 |
# define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/result.hpp>))
|
sl@0
|
110 |
# include BOOST_PP_ITERATE()
|
sl@0
|
111 |
|
sl@0
|
112 |
#elif BOOST_PP_ITERATION_DEPTH() == 2
|
sl@0
|
113 |
# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100) \
|
sl@0
|
114 |
&& BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
|
sl@0
|
115 |
# line BOOST_PP_LINE(__LINE__, result.hpp(pointers-to-members))
|
sl@0
|
116 |
# endif
|
sl@0
|
117 |
// Inner over arities
|
sl@0
|
118 |
|
sl@0
|
119 |
# define N BOOST_PP_ITERATION()
|
sl@0
|
120 |
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
|
sl@0
|
121 |
|
sl@0
|
122 |
template <class R, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
|
sl@0
|
123 |
boost::type<R>* result(R (T::*pmf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q, int = 0)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
return 0;
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
# undef N
|
sl@0
|
129 |
# undef Q
|
sl@0
|
130 |
|
sl@0
|
131 |
#endif
|