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