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