Skip to content

Commit 4320c73

Browse files
committed
Apply more preprocessor optimizations
[SVN r15432]
1 parent 7f98265 commit 4320c73

14 files changed

Lines changed: 102 additions & 73 deletions

include/boost/python/bases.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414
namespace boost { namespace python {
1515

16+
# define BOOST_PYTHON_BASE_PARAMS BOOST_PP_ENUM_PARAMS_Z(1, BOOST_PYTHON_MAX_BASES, B)
17+
1618
// A type list for specifying bases
1719
template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_MAX_BASES, typename B, mpl::void_) >
18-
struct bases : detail::type_list< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) >::type
20+
struct bases : detail::type_list< BOOST_PYTHON_BASE_PARAMS >::type
1921
{};
2022

2123
namespace detail
@@ -25,14 +27,14 @@ namespace boost { namespace python {
2527
{
2628
BOOST_STATIC_CONSTANT(bool, value = false);
2729
};
28-
template < BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, class B) >
29-
struct specifies_bases< bases< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) > >
30+
template < BOOST_PP_ENUM_PARAMS_Z(1, BOOST_PYTHON_MAX_BASES, class B) >
31+
struct specifies_bases< bases< BOOST_PYTHON_BASE_PARAMS > >
3032
{
3133
BOOST_STATIC_CONSTANT(bool, value = true);
3234
};
3335
# else
34-
template < BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, class B) >
35-
static char is_bases_helper(bases< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) > const&);
36+
template < BOOST_PYTHON_BASE_PARAMS >
37+
static char is_bases_helper(bases< BOOST_PYTHON_BASE_PARAMS > const&);
3638

3739
static char (& is_bases_helper(...) )[256];
3840

@@ -55,6 +57,7 @@ namespace boost { namespace python {
5557
{
5658
};
5759
}
60+
# undef BOOST_PYTHON_BASE_PARAMS
5861
}} // namespace boost::python
5962

6063
#endif // BASES_DWA2002321_HPP

include/boost/python/call.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# include <boost/preprocessor/iterate.hpp>
2121
# include <boost/preprocessor/repeat.hpp>
2222
# include <boost/preprocessor/debug/line.hpp>
23+
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
24+
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
2325

2426
namespace boost { namespace python {
2527

@@ -42,11 +44,11 @@ namespace boost { namespace python {
4244

4345
template <
4446
class R
45-
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
47+
BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)
4648
>
4749
typename detail::returnable<R>::type
4850
call(PyObject* callable
49-
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, const& a)
51+
BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a)
5052
, boost::type<R>* = 0
5153
)
5254
{

include/boost/python/call_method.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# include <boost/preprocessor/iterate.hpp>
2020
# include <boost/preprocessor/repeat.hpp>
2121
# include <boost/preprocessor/debug/line.hpp>
22+
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
23+
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
2224

2325
namespace boost { namespace python {
2426

@@ -41,11 +43,11 @@ namespace boost { namespace python {
4143

4244
template <
4345
class R
44-
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
46+
BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)
4547
>
4648
typename detail::returnable<R>::type
4749
call_method(PyObject* self, char const* name
48-
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, const& a)
50+
BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a)
4951
, boost::type<R>* = 0
5052
)
5153
{

include/boost/python/detail/arg_tuple_size.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# include <boost/preprocessor/comma_if.hpp>
2222
# include <boost/preprocessor/iterate.hpp>
2323
# include <boost/preprocessor/debug/line.hpp>
24+
# include <boost/preprocessor/enum_params.hpp>
25+
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
2426

2527
namespace boost { namespace python { namespace detail {
2628

@@ -74,15 +76,15 @@ struct arg_tuple_size
7476

7577
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
7678

77-
template <class R BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
79+
template <class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
7880
struct arg_tuple_size<R (*)(BOOST_PYTHON_UNARY_ENUM(N, A))>
7981
{
8082
BOOST_STATIC_CONSTANT(std::size_t, value = N);
8183
};
8284

8385
# else
8486

85-
template<class R BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
87+
template<class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
8688
char_array<N> arg_tuple_size_helper(
8789
R (*)(BOOST_PYTHON_UNARY_ENUM(N, A)));
8890

@@ -107,17 +109,17 @@ char_array<N> arg_tuple_size_helper(
107109

108110
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
109111

110-
template <class R, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
111-
struct arg_tuple_size<R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q>
112+
template <class R, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
113+
struct arg_tuple_size<R (T::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q>
112114
{
113115
BOOST_STATIC_CONSTANT(std::size_t, value = N + 1U);
114116
};
115117

116118
# else
117119

118-
template <class R, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
120+
template <class R, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
119121
char_array<N + 1> arg_tuple_size_helper(
120-
R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q);
122+
R (T::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q);
121123

122124
# endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
123125

include/boost/python/detail/caller.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
# include <boost/preprocessor/comma_if.hpp>
2525
# include <boost/preprocessor/iterate.hpp>
2626
# include <boost/preprocessor/debug/line.hpp>
27+
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
2728

2829
namespace boost { namespace python
2930
{
@@ -88,7 +89,7 @@ PyObject* operator()(
8889

8990
template <
9091
class P, class R, class T
91-
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
92+
BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)
9293
>
9394
PyObject* operator()(
9495
R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q

include/boost/python/detail/defaults_gen.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct overloads_common
128128
BOOST_PYTHON_TYPEDEF_GEN, \
129129
0) \
130130
\
131-
BOOST_PP_REPEAT_FROM_TO( \
131+
BOOST_PP_REPEAT_FROM_TO_2( \
132132
BOOST_PP_SUB_D(1, n_args, n_dflts), \
133133
BOOST_PP_INC(n_args), \
134134
BOOST_PYTHON_FUNC_WRAPPER_GEN, \
@@ -170,7 +170,7 @@ struct overloads_common
170170
BOOST_PYTHON_TYPEDEF_GEN, \
171171
0) \
172172
\
173-
BOOST_PP_REPEAT_FROM_TO( \
173+
BOOST_PP_REPEAT_FROM_TO_2( \
174174
BOOST_PP_SUB_D(1, n_args, n_dflts), \
175175
BOOST_PP_INC(n_args), \
176176
BOOST_PYTHON_MEM_FUNC_WRAPPER_GEN, \

include/boost/python/detail/member_function_cast.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# include <boost/preprocessor/comma_if.hpp>
1818
# include <boost/preprocessor/iterate.hpp>
1919
# include <boost/preprocessor/debug/line.hpp>
20+
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
2021

2122
namespace boost { namespace python { namespace detail {
2223

@@ -99,7 +100,7 @@ struct member_function_cast
99100

100101
template <
101102
class S, class R
102-
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
103+
BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)
103104
>
104105
static cast_helper<S, R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q>
105106
stage1(R (S::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q)

include/boost/python/detail/result.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# include <boost/preprocessor/comma_if.hpp>
2020
# include <boost/preprocessor/iterate.hpp>
2121
# include <boost/preprocessor/debug/line.hpp>
22+
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
2223

2324
namespace boost { namespace python { namespace detail {
2425

@@ -112,8 +113,8 @@ boost::type<R>* result(R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A)), int = 0)
112113
# define N BOOST_PP_ITERATION()
113114
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
114115

115-
template <class R, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
116-
boost::type<R>* result(R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q, int = 0)
116+
template <class R, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
117+
boost::type<R>* result(R (T::*pmf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q, int = 0)
117118
{
118119
return 0;
119120
}

include/boost/python/detail/returning.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# include <boost/preprocessor/iterate.hpp>
2626
# include <boost/preprocessor/repeat.hpp>
2727
# include <boost/preprocessor/debug/line.hpp>
28+
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
2829

2930
# include <boost/mpl/apply.hpp>
3031

@@ -89,7 +90,7 @@ struct returning<void>
8990

9091
# if (BOOST_PP_ITERATION_FLAGS() & BOOST_PYTHON_RETURNING_NON_VOID)
9192

92-
template<class P BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
93+
template<class P BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
9394
static PyObject* call(
9495
R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A))
9596
, PyObject* args_
@@ -110,7 +111,7 @@ struct returning<void>
110111
}
111112
# elif (BOOST_PP_ITERATION_FLAGS() & BOOST_PYTHON_RETURNING_VOID)
112113

113-
template<class P BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
114+
template<class P BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
114115
static PyObject* call(
115116
R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A))
116117
, PyObject* args_
@@ -155,7 +156,7 @@ struct returning<void>
155156

156157
# if (BOOST_PP_RELATIVE_FLAGS(1) & BOOST_PYTHON_RETURNING_NON_VOID)
157158

158-
template<class P, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
159+
template<class P, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
159160
static PyObject* call(
160161
R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q
161162
, PyObject* args_
@@ -183,7 +184,7 @@ struct returning<void>
183184
}
184185
# elif (BOOST_PP_RELATIVE_FLAGS(1) & BOOST_PYTHON_RETURNING_VOID)
185186

186-
template<class P, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
187+
template<class P, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
187188
static PyObject* call(
188189
R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q
189190
, PyObject* args_

include/boost/python/detail/target.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# include <boost/preprocessor/if.hpp>
1818
# include <boost/preprocessor/iterate.hpp>
1919
# include <boost/preprocessor/debug/line.hpp>
20+
# include <boost/preprocessor/enum_params.hpp>
21+
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
2022

2123
namespace boost { namespace python { namespace detail {
2224

@@ -41,8 +43,8 @@ boost::type<T*>* target(R (T::*)) { return 0; }
4143

4244
# define N BOOST_PP_ITERATION()
4345

44-
template <class R BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
45-
boost::type<BOOST_PP_IF(N, A0, void)>* target(R (*)(BOOST_PYTHON_UNARY_ENUM(N, A)))
46+
template <class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
47+
boost::type<BOOST_PP_IF(N, A0, void)>* target(R (*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)))
4648
{
4749
return 0;
4850
}
@@ -63,7 +65,7 @@ boost::type<BOOST_PP_IF(N, A0, void)>* target(R (*)(BOOST_PYTHON_UNARY_ENUM(N, A
6365
# define N BOOST_PP_ITERATION()
6466
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
6567

66-
template <class R, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
68+
template <class R, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
6769
boost::type<T Q*>* target(R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q)
6870
{
6971
return 0;

0 commit comments

Comments
 (0)