Skip to content

Commit 065a53b

Browse files
committed
Apply more preprocessor optimizations
[SVN r15435]
1 parent ca5a222 commit 065a53b

File tree

14 files changed

+59
-44
lines changed

14 files changed

+59
-44
lines changed

include/boost/python/args.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# include <boost/config.hpp>
99
# include <boost/python/detail/preprocessor.hpp>
1010
# include <boost/python/detail/type_list.hpp>
11+
# include <boost/preprocessor/enum_params.hpp>
1112

1213
namespace boost { namespace python {
1314

@@ -24,8 +25,8 @@ namespace boost { namespace python {
2425

2526
// A type list for specifying arguments
2627
template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, mpl::void_) >
27-
struct args : detail::args_base<args<BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A)> >
28-
, detail::type_list< BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A) >::type
28+
struct args : detail::args_base<args<BOOST_PP_ENUM_PARAMS_Z(1, BOOST_PYTHON_MAX_ARITY, A)> >
29+
, detail::type_list< BOOST_PP_ENUM_PARAMS_Z(1, BOOST_PYTHON_MAX_ARITY, A) >::type
2930
{};
3031

3132
}} // namespace boost::python

include/boost/python/detail/arg_tuple_size.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct arg_tuple_size
7777
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
7878

7979
template <class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
80-
struct arg_tuple_size<R (*)(BOOST_PYTHON_UNARY_ENUM(N, A))>
80+
struct arg_tuple_size<R (*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A))>
8181
{
8282
BOOST_STATIC_CONSTANT(std::size_t, value = N);
8383
};
@@ -86,7 +86,7 @@ struct arg_tuple_size<R (*)(BOOST_PYTHON_UNARY_ENUM(N, A))>
8686

8787
template<class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
8888
char_array<N> arg_tuple_size_helper(
89-
R (*)(BOOST_PYTHON_UNARY_ENUM(N, A)));
89+
R (*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)));
9090

9191
# endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
9292

include/boost/python/detail/caller.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ struct caller
6161

6262
template <
6363
class P, class R
64-
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
64+
BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)
6565
>
6666
PyObject* operator()(
67-
R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A))
67+
R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A))
6868
, PyObject* args
6969
, PyObject* keywords
7070
, P const& policies) const
@@ -92,7 +92,7 @@ template <
9292
BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)
9393
>
9494
PyObject* operator()(
95-
R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q
95+
R (T::*pmf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q
9696
, PyObject* args, PyObject* keywords
9797
, P const& policies
9898
) const

include/boost/python/detail/defaults_gen.hpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <boost/preprocessor/repeat_from_to.hpp>
1616
#include <boost/preprocessor/enum.hpp>
1717
#include <boost/preprocessor/enum_params.hpp>
18+
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
1819
#include <boost/preprocessor/tuple.hpp>
1920
#include <boost/preprocessor/cat.hpp>
2021
#include <boost/preprocessor/arithmetic/sub.hpp>
@@ -97,17 +98,17 @@ struct overloads_common
9798
BOOST_PP_CAT(iter, BOOST_PP_INC(index)); \
9899
typedef typename BOOST_PP_CAT(iter, index)::type BOOST_PP_CAT(T, index); \
99100

100-
#define BOOST_PYTHON_FUNC_WRAPPER_GEN(z, index, data) \
101-
static RT BOOST_PP_CAT(func_, \
102-
BOOST_PP_SUB_D(1, index, BOOST_PP_TUPLE_ELEM(3, 1, data))) ( \
103-
BOOST_PYTHON_BINARY_ENUM( \
104-
index, T, arg)) \
105-
{ \
106-
BOOST_PP_TUPLE_ELEM(3, 2, data) \
107-
BOOST_PP_TUPLE_ELEM(3, 0, data)( \
108-
BOOST_PP_ENUM_PARAMS( \
109-
index, \
110-
arg)); \
101+
#define BOOST_PYTHON_FUNC_WRAPPER_GEN(z, index, data) \
102+
static RT BOOST_PP_CAT(func_, \
103+
BOOST_PP_SUB_D(1, index, BOOST_PP_TUPLE_ELEM(3, 1, data))) ( \
104+
BOOST_PP_ENUM_BINARY_PARAMS_Z( \
105+
1, index, T, arg)) \
106+
{ \
107+
BOOST_PP_TUPLE_ELEM(3, 2, data) \
108+
BOOST_PP_TUPLE_ELEM(3, 0, data)( \
109+
BOOST_PP_ENUM_PARAMS( \
110+
index, \
111+
arg)); \
111112
}
112113

113114
#define BOOST_PYTHON_GEN_FUNCTION(fname, fstubs_name, n_args, n_dflts, ret) \
@@ -141,7 +142,7 @@ struct overloads_common
141142
static RT BOOST_PP_CAT(func_, \
142143
BOOST_PP_SUB_D(1, index, BOOST_PP_TUPLE_ELEM(3, 1, data))) ( \
143144
ClassT& obj BOOST_PP_COMMA_IF(index) \
144-
BOOST_PYTHON_BINARY_ENUM(index, T, arg) \
145+
BOOST_PP_ENUM_BINARY_PARAMS_Z(1, index, T, arg) \
145146
) \
146147
{ \
147148
BOOST_PP_TUPLE_ELEM(3, 2, data) obj.BOOST_PP_TUPLE_ELEM(3, 0, data)( \

include/boost/python/detail/make_tuple.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
, python::incref(python::object(a##N).ptr()) \
1818
);
1919

20-
template <BOOST_PYTHON_UNARY_ENUM(N, class A)>
20+
template <BOOST_PP_ENUM_PARAMS_Z(1, N, class A)>
2121
tuple
22-
make_tuple(BOOST_PYTHON_BINARY_ENUM(N, A, const& a))
22+
make_tuple(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a))
2323
{
2424
tuple result((detail::new_reference)::PyTuple_New(N));
2525
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_MAKE_TUPLE_ARG, _)

include/boost/python/detail/member_function_cast.hpp

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

2224
namespace boost { namespace python { namespace detail {
@@ -97,17 +99,19 @@ struct member_function_cast
9799

98100
# define N BOOST_PP_ITERATION()
99101
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
102+
# define P BOOST_PP_ENUM_PARAMS_Z(1, N, A)
100103

101104
template <
102105
class S, class R
103106
BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)
104107
>
105-
static cast_helper<S, R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q>
106-
stage1(R (S::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q)
108+
static cast_helper<S, R (T::*)( P ) Q>
109+
stage1(R (S::*)( P ) Q)
107110
{
108-
return cast_helper<S, R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q>();
111+
return cast_helper<S, R (T::*)( P ) Q>();
109112
}
110113

114+
# undef P
111115
# undef N
112116
# undef Q
113117

include/boost/python/detail/result.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ result(X const&, short = 0) { return 0; }
9292

9393
# define N BOOST_PP_ITERATION()
9494

95-
template <class R BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
96-
boost::type<R>* result(R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A)), int = 0)
95+
template <class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
96+
boost::type<R>* result(R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)), int = 0)
9797
{
9898
return 0;
9999
}

include/boost/python/detail/returning.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct returning<void>
9292

9393
template<class P BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
9494
static PyObject* call(
95-
R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A))
95+
R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A))
9696
, PyObject* args_
9797
, PyObject*, P const* policies)
9898
{
@@ -113,7 +113,7 @@ struct returning<void>
113113

114114
template<class P BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
115115
static PyObject* call(
116-
R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A))
116+
R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A))
117117
, PyObject* args_
118118
, PyObject*, P const* policies)
119119
{
@@ -158,7 +158,7 @@ struct returning<void>
158158

159159
template<class P, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
160160
static PyObject* call(
161-
R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q
161+
R (T::*pmf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q
162162
, PyObject* args_
163163
, PyObject*, P const* policies)
164164
{
@@ -186,7 +186,7 @@ struct returning<void>
186186

187187
template<class P, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
188188
static PyObject* call(
189-
R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q
189+
R (T::*pmf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q
190190
, PyObject* args_
191191
, PyObject*, P const* policies)
192192
{

include/boost/python/detail/target.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ boost::type<BOOST_PP_IF(N, A0, void)>* target(R (*)(BOOST_PP_ENUM_PARAMS_Z(1, N,
6666
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
6767

6868
template <class R, class T BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)>
69-
boost::type<T Q*>* target(R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q)
69+
boost::type<T Q*>* target(R (T::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q)
7070
{
7171
return 0;
7272
}

include/boost/python/object/make_holder.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# include <boost/preprocessor/iterate.hpp>
2424
# include <boost/preprocessor/repeat.hpp>
2525
# include <boost/preprocessor/debug/line.hpp>
26+
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
2627

2728
# include <cstddef>
2829

@@ -64,7 +65,7 @@ struct make_holder<N>
6465
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FORWARD_ARG, nil)
6566
static void execute(
6667
PyObject* p
67-
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, t, a))
68+
BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, t, a))
6869
{
6970
typedef instance<Holder> instance_t;
7071

0 commit comments

Comments
 (0)