From 065a53b997c9803498b39e833c42e41dd96d4693 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 18 Sep 2002 04:54:31 +0000 Subject: [PATCH] Apply more preprocessor optimizations [SVN r15435] --- include/boost/python/args.hpp | 5 ++-- .../boost/python/detail/arg_tuple_size.hpp | 4 +-- include/boost/python/detail/caller.hpp | 6 ++--- include/boost/python/detail/defaults_gen.hpp | 25 ++++++++++--------- include/boost/python/detail/make_tuple.hpp | 4 +-- .../python/detail/member_function_cast.hpp | 10 +++++--- include/boost/python/detail/result.hpp | 4 +-- include/boost/python/detail/returning.hpp | 8 +++--- include/boost/python/detail/target.hpp | 2 +- include/boost/python/object/make_holder.hpp | 3 ++- .../boost/python/object/pointer_holder.hpp | 12 +++++---- include/boost/python/object/value_holder.hpp | 12 ++++++--- include/boost/python/object_call.hpp | 6 ++--- include/boost/python/tuple.hpp | 2 ++ 14 files changed, 59 insertions(+), 44 deletions(-) diff --git a/include/boost/python/args.hpp b/include/boost/python/args.hpp index 941529f0..e488f3d8 100644 --- a/include/boost/python/args.hpp +++ b/include/boost/python/args.hpp @@ -8,6 +8,7 @@ # include # include # include +# include namespace boost { namespace python { @@ -24,8 +25,8 @@ namespace boost { namespace python { // A type list for specifying arguments template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, mpl::void_) > -struct args : detail::args_base > - , detail::type_list< BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A) >::type +struct args : detail::args_base > + , detail::type_list< BOOST_PP_ENUM_PARAMS_Z(1, BOOST_PYTHON_MAX_ARITY, A) >::type {}; }} // namespace boost::python diff --git a/include/boost/python/detail/arg_tuple_size.hpp b/include/boost/python/detail/arg_tuple_size.hpp index 1d534ae8..88900702 100644 --- a/include/boost/python/detail/arg_tuple_size.hpp +++ b/include/boost/python/detail/arg_tuple_size.hpp @@ -77,7 +77,7 @@ struct arg_tuple_size # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template -struct arg_tuple_size +struct arg_tuple_size { BOOST_STATIC_CONSTANT(std::size_t, value = N); }; @@ -86,7 +86,7 @@ struct arg_tuple_size template char_array arg_tuple_size_helper( - R (*)(BOOST_PYTHON_UNARY_ENUM(N, A))); + R (*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A))); # endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) diff --git a/include/boost/python/detail/caller.hpp b/include/boost/python/detail/caller.hpp index 99612b01..9d390dbd 100644 --- a/include/boost/python/detail/caller.hpp +++ b/include/boost/python/detail/caller.hpp @@ -61,10 +61,10 @@ struct caller template < class P, class R - BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A) + BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A) > PyObject* operator()( - R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A)) + R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) , PyObject* args , PyObject* keywords , P const& policies) const @@ -92,7 +92,7 @@ template < BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A) > PyObject* operator()( - R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q + R (T::*pmf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q , PyObject* args, PyObject* keywords , P const& policies ) const diff --git a/include/boost/python/detail/defaults_gen.hpp b/include/boost/python/detail/defaults_gen.hpp index 29c07610..d8b96d53 100644 --- a/include/boost/python/detail/defaults_gen.hpp +++ b/include/boost/python/detail/defaults_gen.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -97,17 +98,17 @@ struct overloads_common BOOST_PP_CAT(iter, BOOST_PP_INC(index)); \ typedef typename BOOST_PP_CAT(iter, index)::type BOOST_PP_CAT(T, index); \ -#define BOOST_PYTHON_FUNC_WRAPPER_GEN(z, index, data) \ - static RT BOOST_PP_CAT(func_, \ - BOOST_PP_SUB_D(1, index, BOOST_PP_TUPLE_ELEM(3, 1, data))) ( \ - BOOST_PYTHON_BINARY_ENUM( \ - index, T, arg)) \ - { \ - BOOST_PP_TUPLE_ELEM(3, 2, data) \ - BOOST_PP_TUPLE_ELEM(3, 0, data)( \ - BOOST_PP_ENUM_PARAMS( \ - index, \ - arg)); \ +#define BOOST_PYTHON_FUNC_WRAPPER_GEN(z, index, data) \ + static RT BOOST_PP_CAT(func_, \ + BOOST_PP_SUB_D(1, index, BOOST_PP_TUPLE_ELEM(3, 1, data))) ( \ + BOOST_PP_ENUM_BINARY_PARAMS_Z( \ + 1, index, T, arg)) \ + { \ + BOOST_PP_TUPLE_ELEM(3, 2, data) \ + BOOST_PP_TUPLE_ELEM(3, 0, data)( \ + BOOST_PP_ENUM_PARAMS( \ + index, \ + arg)); \ } #define BOOST_PYTHON_GEN_FUNCTION(fname, fstubs_name, n_args, n_dflts, ret) \ @@ -141,7 +142,7 @@ struct overloads_common static RT BOOST_PP_CAT(func_, \ BOOST_PP_SUB_D(1, index, BOOST_PP_TUPLE_ELEM(3, 1, data))) ( \ ClassT& obj BOOST_PP_COMMA_IF(index) \ - BOOST_PYTHON_BINARY_ENUM(index, T, arg) \ + BOOST_PP_ENUM_BINARY_PARAMS_Z(1, index, T, arg) \ ) \ { \ BOOST_PP_TUPLE_ELEM(3, 2, data) obj.BOOST_PP_TUPLE_ELEM(3, 0, data)( \ diff --git a/include/boost/python/detail/make_tuple.hpp b/include/boost/python/detail/make_tuple.hpp index 07cd9903..cb5c6fc6 100644 --- a/include/boost/python/detail/make_tuple.hpp +++ b/include/boost/python/detail/make_tuple.hpp @@ -17,9 +17,9 @@ , python::incref(python::object(a##N).ptr()) \ ); - template + template tuple - make_tuple(BOOST_PYTHON_BINARY_ENUM(N, A, const& a)) + make_tuple(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a)) { tuple result((detail::new_reference)::PyTuple_New(N)); BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_MAKE_TUPLE_ARG, _) diff --git a/include/boost/python/detail/member_function_cast.hpp b/include/boost/python/detail/member_function_cast.hpp index a491494f..568c13cc 100644 --- a/include/boost/python/detail/member_function_cast.hpp +++ b/include/boost/python/detail/member_function_cast.hpp @@ -17,6 +17,8 @@ # include # include # include + +# include # include namespace boost { namespace python { namespace detail { @@ -97,17 +99,19 @@ struct member_function_cast # define N BOOST_PP_ITERATION() # define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1)) +# define P BOOST_PP_ENUM_PARAMS_Z(1, N, A) template < class S, class R BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A) > - static cast_helper - stage1(R (S::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q) + static cast_helper + stage1(R (S::*)( P ) Q) { - return cast_helper(); + return cast_helper(); } +# undef P # undef N # undef Q diff --git a/include/boost/python/detail/result.hpp b/include/boost/python/detail/result.hpp index 2e955e23..bb66f13a 100755 --- a/include/boost/python/detail/result.hpp +++ b/include/boost/python/detail/result.hpp @@ -92,8 +92,8 @@ result(X const&, short = 0) { return 0; } # define N BOOST_PP_ITERATION() -template -boost::type* result(R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A)), int = 0) +template +boost::type* result(R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)), int = 0) { return 0; } diff --git a/include/boost/python/detail/returning.hpp b/include/boost/python/detail/returning.hpp index 39941a39..97338ff3 100644 --- a/include/boost/python/detail/returning.hpp +++ b/include/boost/python/detail/returning.hpp @@ -92,7 +92,7 @@ struct returning template static PyObject* call( - R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A)) + R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) , PyObject* args_ , PyObject*, P const* policies) { @@ -113,7 +113,7 @@ struct returning template static PyObject* call( - R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A)) + R (*pf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) , PyObject* args_ , PyObject*, P const* policies) { @@ -158,7 +158,7 @@ struct returning template static PyObject* call( - R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q + R (T::*pmf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q , PyObject* args_ , PyObject*, P const* policies) { @@ -186,7 +186,7 @@ struct returning template static PyObject* call( - R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q + R (T::*pmf)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q , PyObject* args_ , PyObject*, P const* policies) { diff --git a/include/boost/python/detail/target.hpp b/include/boost/python/detail/target.hpp index d8983dae..67007720 100644 --- a/include/boost/python/detail/target.hpp +++ b/include/boost/python/detail/target.hpp @@ -66,7 +66,7 @@ boost::type* target(R (*)(BOOST_PP_ENUM_PARAMS_Z(1, N, # define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1)) template -boost::type* target(R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q) +boost::type* target(R (T::*)(BOOST_PP_ENUM_PARAMS_Z(1, N, A)) Q) { return 0; } diff --git a/include/boost/python/object/make_holder.hpp b/include/boost/python/object/make_holder.hpp index 2a9e4e58..ebcddc0d 100644 --- a/include/boost/python/object/make_holder.hpp +++ b/include/boost/python/object/make_holder.hpp @@ -23,6 +23,7 @@ # include # include # include +# include # include @@ -64,7 +65,7 @@ struct make_holder BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FORWARD_ARG, nil) static void execute( PyObject* p - BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, t, a)) + BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, t, a)) { typedef instance instance_t; diff --git a/include/boost/python/object/pointer_holder.hpp b/include/boost/python/object/pointer_holder.hpp index 0dca4ae3..d0196941 100644 --- a/include/boost/python/object/pointer_holder.hpp +++ b/include/boost/python/object/pointer_holder.hpp @@ -20,7 +20,6 @@ # include # include # include -# include # include # include @@ -28,6 +27,9 @@ # include # include # include +# include +# include +# include namespace boost { namespace python { namespace objects { @@ -127,9 +129,9 @@ void* pointer_holder_back_reference::holds(type_info dst_t) # define N BOOST_PP_ITERATION() # if (N != 0) - template< BOOST_PYTHON_UNARY_ENUM(N, class A) > + template< BOOST_PP_ENUM_PARAMS_Z(1, N, class A) > # endif - pointer_holder(PyObject* BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, a)) + pointer_holder(PyObject* BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, a)) : m_p(new Value( BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil) )) @@ -144,10 +146,10 @@ void* pointer_holder_back_reference::holds(type_info dst_t) # define N BOOST_PP_ITERATION() # if (N != 0) - template < BOOST_PYTHON_UNARY_ENUM(N, class A) > + template < BOOST_PP_ENUM_PARAMS_Z(1, N, class A) > # endif pointer_holder_back_reference( - PyObject* p BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, a)) + PyObject* p BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, a)) : m_p(new held_type( p BOOST_PP_COMMA_IF(N) BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil) )) diff --git a/include/boost/python/object/value_holder.hpp b/include/boost/python/object/value_holder.hpp index d40d058d..95b58746 100644 --- a/include/boost/python/object/value_holder.hpp +++ b/include/boost/python/object/value_holder.hpp @@ -19,10 +19,14 @@ # include # include +# include # include # include # include +# include +# include + namespace boost { namespace python { namespace objects { # define BOOST_PYTHON_UNFORWARD_LOCAL(z, n, _) BOOST_PP_COMMA_IF(n) (typename unforward::type)(a##n) @@ -96,10 +100,10 @@ void* value_holder_back_reference::holds( # define N BOOST_PP_ITERATION() # if (N != 0) - template + template # endif value_holder( - PyObject* BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, a)) + PyObject* BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, a)) : m_held( BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil) ) @@ -115,10 +119,10 @@ void* value_holder_back_reference::holds( # define N BOOST_PP_ITERATION() # if (N != 0) - template + template # endif value_holder_back_reference( - PyObject* p BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, a)) + PyObject* p BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, a)) : m_held( p BOOST_PP_COMMA_IF(N) BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil) diff --git a/include/boost/python/object_call.hpp b/include/boost/python/object_call.hpp index 31b2eff9..362446b2 100644 --- a/include/boost/python/object_call.hpp +++ b/include/boost/python/object_call.hpp @@ -10,13 +10,13 @@ #define N BOOST_PP_ITERATION() - template + template typename detail::dependent::type - operator()(BOOST_PYTHON_BINARY_ENUM(N, A, const& a)) const + operator()(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A, const& a)) const { typedef typename detail::dependent::type obj; U const& self = *static_cast(this); - return call(get_managed_object(self, tag), BOOST_PYTHON_UNARY_ENUM(N, a)); + return call(get_managed_object(self, tag), BOOST_PP_ENUM_PARAMS_Z(1, N, a)); } #undef N diff --git a/include/boost/python/tuple.hpp b/include/boost/python/tuple.hpp index 38547696..2ab4ad73 100644 --- a/include/boost/python/tuple.hpp +++ b/include/boost/python/tuple.hpp @@ -3,6 +3,8 @@ #include #include +#include +#include namespace boost { namespace python {