Skip to content

Commit 8388163

Browse files
committed
corrected BOOST_PYTHON_MAX_ARITY response
made things compile in time on EDG increased BOOST_PYTHON_DEBUGGABLE_ARITY to 15 [SVN r13519]
1 parent a203214 commit 8388163

15 files changed

Lines changed: 7604 additions & 2148 deletions

include/boost/python/args.hpp

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,69 @@
55
// to its suitability for any purpose.
66
#ifndef ARGS_DWA2002323_HPP
77
# define ARGS_DWA2002323_HPP
8+
# include <boost/config.hpp>
89
# include <boost/mpl/type_list.hpp>
10+
# include <boost/python/detail/preprocessor.hpp>
11+
# include <boost/preprocessor/enum_params.hpp>
12+
# include <boost/preprocessor/enum_params_with_a_default.hpp>
13+
# include <boost/preprocessor/comma_if.hpp>
914

15+
# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245
1016
namespace boost { namespace python {
1117

18+
1219
// A type list for specifying arguments
13-
template < BOOST_MPL_LIST_DEFAULT_PARAMETERS(typename A, ::boost::mpl::null_argument) >
14-
struct args : ::boost::mpl::type_list< BOOST_MPL_LIST_PARAMETERS(A) >::type
20+
template < BOOST_MPL_LIST_DEFAULT_PARAMETERS(typename A, boost::mpl::null_argument) >
21+
struct args : boost::mpl::type_list< BOOST_MPL_LIST_PARAMETERS(A) >::type
1522
{};
1623

1724
}} // namespace boost::python
1825

26+
# else // slow template instantiators need this other version with
27+
// explicit specializations of mpl::size<> and
28+
// mpl::at<>. Eventually, however, inheritance from mpl::list
29+
// *should* be eliminated and the two versions unified, just in
30+
// order to get true arity independence
31+
32+
namespace boost { namespace python {
33+
34+
template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_MAX_ARITY, class A, boost::mpl::null_argument) >
35+
struct args
36+
{};
37+
38+
}} // namespace boost::python
39+
40+
namespace boost { namespace mpl {
41+
42+
template <class T> struct size;
43+
template <long N, class Seq> struct at;
44+
45+
# ifndef BOOST_PYTHON_GENERATE_CODE
46+
# include <boost/python/preprocessed/args.hpp>
47+
# endif
48+
49+
# define BOOST_PYTHON_ARGS_SIZE(index,ignored) \
50+
template <BOOST_PP_ENUM_PARAMS(index, class A)> \
51+
struct size<boost::python::args<BOOST_PP_ENUM_PARAMS(index, A)> > \
52+
{ \
53+
BOOST_STATIC_CONSTANT(long, value = index); \
54+
}; \
55+
56+
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_ARGS_SIZE, nil)
57+
58+
# define BOOST_PYTHON_ARGS_AT(index,ignored) \
59+
template < \
60+
BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH), class A)> \
61+
struct at<index, boost::python::args< \
62+
BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH), A)> > \
63+
{ \
64+
typedef BOOST_PP_CAT(A,index) type; \
65+
}; \
66+
67+
BOOST_PP_REPEAT_FROM_TO_2ND(
68+
BOOST_PP_DEC(BOOST_PYTHON_ARITY_START), BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH)
69+
, BOOST_PYTHON_ARGS_AT, data)
70+
71+
}}
72+
# endif
1973
#endif // ARGS_DWA2002323_HPP

include/boost/python/detail/preprocessor.hpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ namespace boost { namespace python { namespace detail {
3535
# endif
3636

3737
#ifndef BOOST_PYTHON_DEBUGGABLE_ARITY
38-
# define BOOST_PYTHON_DEBUGGABLE_ARITY 10
38+
# define BOOST_PYTHON_DEBUGGABLE_ARITY 15
3939
#endif
4040

4141
#ifndef BOOST_PYTHON_MAX_ARITY
4242
# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245
4343
// Generate at least two more arguments just to test the syntax
44-
# define BOOST_PYTHON_MAX_ARITY 12
44+
# define BOOST_PYTHON_MAX_ARITY 17
4545
# else
4646
// Current EDG compilers have a really slow preprocessor which makes
4747
// it important not to generate new functions with it unless
@@ -53,16 +53,18 @@ namespace boost { namespace python { namespace detail {
5353
#ifdef BOOST_PYTHON_GENERATE_CODE
5454
# undef BOOST_STATIC_CONSTANT
5555
# define BOOST_PYTHON_ARITY_START 0
56-
# define BOOST_PYTHON_ARITY_FINISH BOOST_PYTHON_DEBUGGABLE_ARITY
56+
# define BOOST_PYTHON_ARITY_FINISH BOOST_PP_INC(BOOST_PYTHON_DEBUGGABLE_ARITY)
5757
# define BOOST_PYTHON_MF_ARITY_START 1
58-
# define BOOST_PYTHON_MF_ARITY_FINISH BOOST_PP_INC(BOOST_PYTHON_DEBUGGABLE_ARITY)
58+
# define BOOST_PYTHON_MF_ARITY_FINISH BOOST_PP_INC(BOOST_PP_INC(BOOST_PYTHON_DEBUGGABLE_ARITY))
5959
#else
60-
# define BOOST_PYTHON_ARITY_START BOOST_PYTHON_DEBUGGABLE_ARITY
61-
# define BOOST_PYTHON_ARITY_FINISH BOOST_PYTHON_MAX_ARITY
62-
# define BOOST_PYTHON_MF_ARITY_START BOOST_PP_INC(BOOST_PYTHON_DEBUGGABLE_ARITY)
63-
# define BOOST_PYTHON_MF_ARITY_FINISH BOOST_PP_INC(BOOST_PYTHON_MAX_ARITY)
60+
# define BOOST_PYTHON_ARITY_START BOOST_PP_INC(BOOST_PYTHON_DEBUGGABLE_ARITY)
61+
# define BOOST_PYTHON_ARITY_FINISH BOOST_PP_INC(BOOST_PYTHON_MAX_ARITY)
62+
# define BOOST_PYTHON_MF_ARITY_START BOOST_PP_INC(BOOST_PP_INC(BOOST_PYTHON_DEBUGGABLE_ARITY))
63+
# define BOOST_PYTHON_MF_ARITY_FINISH BOOST_PP_INC(BOOST_PP_INC(BOOST_PYTHON_MAX_ARITY))
6464
#endif
6565

66+
#if BOOST_PYTHON_MAX_ARITY > BOOST_PYTHON_DEBUGGABLE_ARITY
67+
6668
# define BOOST_PYTHON_FN(inner,start,count) \
6769
R(inner)(BOOST_MPL_TEMPLATE_PARAMETERS(start,count,A))
6870

@@ -93,6 +95,15 @@ namespace boost { namespace python { namespace detail {
9395

9496
# define BOOST_PYTHON_PROJECT_1ST(a1,a2) a1
9597
# define BOOST_PYTHON_PROJECT_2ND(a1,a2) a2
98+
#else
99+
100+
# define BOOST_PYTHON_REPEAT_ARITY_2ND(function,data)
101+
# define BOOST_PYTHON_REPEAT_MF_ARITY_2ND(function,data)
102+
# define BOOST_PYTHON_REPEAT_MF_ALL_CV_2ND(function)
103+
# define BOOST_PYTHON_REPEAT_MF_CV_2ND(function)
104+
# define BOOST_PYTHON_REPEAT_PMF_CV(index, function, cv)
105+
106+
#endif
96107

97108
}}} // namespace boost::python::detail
98109

0 commit comments

Comments
 (0)