2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-26 18:52:26 +00:00

Works with arbitrary arity, MSVC6

[SVN r15310]
This commit is contained in:
Dave Abrahams
2002-09-13 22:35:45 +00:00
parent c7eae3512f
commit fd1d332d3f
25 changed files with 343 additions and 280 deletions

View File

@@ -1,5 +1,3 @@
#if !defined(BOOST_PP_IS_ITERATING)
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
@@ -8,15 +6,8 @@
#ifndef ARGS_DWA2002323_HPP
# define ARGS_DWA2002323_HPP
# include <boost/config.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/list.hpp>
# include <boost/mpl/at.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/debug/line.hpp>
# include <boost/python/detail/type_list.hpp>
namespace boost { namespace python {
@@ -29,76 +20,15 @@ namespace detail
}
}}
# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245
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<args<BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A)> >
, mpl::list< BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A) >::type
, detail::type_list< BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A) >::type
{};
}} // namespace boost::python
# else // slow template instantiators need this other version with
// explicit specializations of mpl::size<> and
// mpl::at_c<>. Eventually, however, inheritance from mpl::list
// *should* be eliminated and the two versions unified, just in
// order to get true arity independence
namespace boost { namespace python {
template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, mpl::void_) >
struct args : detail::args_base<args<BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A)> >
{};
}} // namespace boost::python
namespace boost { namespace mpl {
template <class T> struct size;
template <long N, class Seq> struct at;
# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/args.hpp>, 1))
# include BOOST_PP_ITERATE()
# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY - 1, <boost/python/args.hpp>, 2))
# include BOOST_PP_ITERATE()
}} // namespace boost::mpl
# endif // __EDG_VERSION__
# endif // ARGS_DWA2002323_HPP
/* ---------- size ---------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 1
# line BOOST_PP_LINE(__LINE__, args.hpp(size))
# define N BOOST_PP_ITERATION()
template <BOOST_PYTHON_UNARY_ENUM(N, class A)>
struct size<boost::python::args<BOOST_PYTHON_UNARY_ENUM(N, A)> >
{
BOOST_STATIC_CONSTANT(long, value = N);
};
# undef N
/* ---------- at_c ---------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 2
# line BOOST_PP_LINE(__LINE__, args.hpp(at))
# define N BOOST_PP_ITERATION()
template <BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, class A)>
struct at_c<N, boost::python::args<BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A)> >
{
typedef BOOST_PP_CAT(A, N) type;
};
# undef N
#endif

View File

@@ -6,15 +6,16 @@
#ifndef BASES_DWA2002321_HPP
# define BASES_DWA2002321_HPP
# include <boost/type_traits/object_traits.hpp>
# include <boost/mpl/list.hpp>
# include <boost/python/detail/type_list.hpp>
# include <boost/mpl/if.hpp>
# include <boost/preprocessor/enum_params_with_a_default.hpp>
# include <boost/preprocessor/enum_params.hpp>
namespace boost { namespace python {
// A type list for specifying bases
template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_MPL_LIMIT_LIST_SIZE, typename B, mpl::void_) >
struct bases : mpl::list< BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE, B) >::type
template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_MAX_BASES, typename B, mpl::void_) >
struct bases : detail::type_list< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) >::type
{};
namespace detail
@@ -24,14 +25,14 @@ namespace boost { namespace python {
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
template < BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE, class B) >
struct specifies_bases< bases< BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE, B) > >
template < BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, class B) >
struct specifies_bases< bases< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) > >
{
BOOST_STATIC_CONSTANT(bool, value = true);
};
# else
template < BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE, class B) >
static char is_bases_helper(bases< BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_LIST_SIZE, B) > const&);
template < BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, class B) >
static char is_bases_helper(bases< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) > const&);
static char (& is_bases_helper(...) )[256];

View File

@@ -54,8 +54,8 @@ call(PyObject* callable
return converter(
PyEval_CallFunction(
callable
, const_cast<char*>("(" BOOST_PP_REPEAT(N, BOOST_PYTHON_FIXED, "O") ")")
BOOST_PP_REPEAT(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
, const_cast<char*>("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")")
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
));
}

View File

@@ -54,8 +54,8 @@ call_method(PyObject* self, char const* name
PyEval_CallMethod(
self
, const_cast<char*>(name)
, const_cast<char*>("(" BOOST_PP_REPEAT(N, BOOST_PYTHON_FIXED, "O") ")")
BOOST_PP_REPEAT(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
, const_cast<char*>("(" BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FIXED, "O") ")")
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
));
}

View File

@@ -280,7 +280,7 @@ class class_ : public objects::class_base
// Define the default constructor.
self& def_init()
{
this->def_init(mpl::list<>::type());
this->def_init(mpl::list0<>::type());
return *this;
}

View File

@@ -106,4 +106,12 @@ class function;
}}}
#endif
#if (defined(__DECCXX_VER) && __DECCXX_VER <= 60590014)
// Replace broken Tru64/cxx offsetof macro
# define BOOST_PYTHON_OFFSETOF(s_name, s_member) \
((size_t)__INTADDR__(&(((s_name *)0)->s_member)))
#else
# define BOOST_PYTHON_OFFSETOF offsetof
#endif
#endif // CONFIG_DWA052200_H_

View File

@@ -14,10 +14,10 @@
#include <boost/python/detail/defaults_gen.hpp>
#include <boost/type_traits.hpp>
#include <boost/mpl/int_c.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/static_assert.hpp>
#include <boost/preprocessor/iterate.hpp>
#include <boost/python/detail/type_list_utils.hpp>
#include <boost/python/class_fwd.hpp>
#include <boost/python/object/function.hpp>
#include <boost/python/scope.hpp>
@@ -201,19 +201,18 @@ struct define_stub_function {};
SigT sig,
char const* doc)
{
typedef typename boost::python::detail::type_at<0, SigT>::type nth_type;
typedef typename mpl::front<SigT>::type return_type;
typedef typename StubsT::v_type v_type;
typedef typename StubsT::nv_type nv_type;
typedef typename mpl::if_c<
boost::is_same<void, nth_type>::value
boost::is_same<void, return_type>::value
, v_type
, nv_type
>::type stubs_type;
BOOST_STATIC_ASSERT(
(stubs_type::max_args) <=
boost::python::detail::type_list_size<SigT>::value);
(stubs_type::max_args) <= mpl::size<SigT>::value);
typedef typename stubs_type::template gen<SigT> gen_type;
define_with_defaults_helper<stubs_type::n_funcs-1>::def

View File

@@ -23,7 +23,8 @@
#include <boost/preprocessor/empty.hpp>
#include <boost/preprocessor/comma_if.hpp>
#include <boost/config.hpp>
#include <boost/python/detail/type_list_utils.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/front.hpp>
namespace boost { namespace python { namespace detail {
@@ -39,23 +40,23 @@ struct func_stubs_base {};
///////////////////////////////////////////////////////////////////////////////
#define BPL_IMPL_TYPEDEF_GEN(z, INDEX, DATA) \
typedef typename boost::python::detail::type_at \
typedef typename ::boost::mpl::at_c \
< \
BOOST_PP_ADD(INDEX, DATA), \
BOOST_PP_ADD_D(1, INDEX, DATA), \
SigT \
>::type BOOST_PP_CAT(T, INDEX); \
#define BPL_IMPL_FUNC_WRAPPER_GEN(z, index, DATA) \
static RT BOOST_PP_CAT(func_, index) ( \
BOOST_PYTHON_BINARY_ENUM( \
BOOST_PP_ADD(BOOST_PP_TUPLE_ELEM(3, 1, DATA), index), T, arg) \
BOOST_PP_ADD_D(1, BOOST_PP_TUPLE_ELEM(3, 1, DATA), index), T, arg) \
) \
{ \
BOOST_PP_TUPLE_ELEM(3, 2, DATA) \
BOOST_PP_TUPLE_ELEM(3, 0, DATA) \
( \
BOOST_PP_ENUM_PARAMS( \
BOOST_PP_ADD(BOOST_PP_TUPLE_ELEM(3, 1, DATA), index), \
BOOST_PP_ADD_D(1, BOOST_PP_TUPLE_ELEM(3, 1, DATA), index), \
arg \
) \
); \
@@ -70,7 +71,7 @@ struct func_stubs_base {};
template <typename SigT> \
struct gen { \
\
typedef typename boost::python::detail::type_at<0, SigT>::type RT; \
typedef typename ::boost::mpl::front<SigT>::type RT; \
\
BOOST_PP_REPEAT_2ND \
( \
@@ -83,7 +84,7 @@ struct func_stubs_base {};
( \
BOOST_PP_INC(N_DFLTS), \
BPL_IMPL_FUNC_WRAPPER_GEN, \
(FNAME, BOOST_PP_SUB(N_ARGS, N_DFLTS), RETURN) \
(FNAME, BOOST_PP_SUB_D(1, N_ARGS, N_DFLTS), RETURN) \
) \
}; \
}; \
@@ -92,14 +93,14 @@ struct func_stubs_base {};
#define BPL_IMPL_MEM_FUNC_WRAPPER_GEN(z, index, DATA) \
static RT BOOST_PP_CAT(func_, index) ( \
ClassT& obj BOOST_PP_COMMA_IF( \
BOOST_PP_ADD(BOOST_PP_TUPLE_ELEM(3, 1, DATA), index)) \
BOOST_PP_ADD_D(1, BOOST_PP_TUPLE_ELEM(3, 1, DATA), index)) \
BOOST_PYTHON_BINARY_ENUM( \
BOOST_PP_ADD(BOOST_PP_TUPLE_ELEM(3, 1, DATA), index), T, arg) \
BOOST_PP_ADD_D(1, BOOST_PP_TUPLE_ELEM(3, 1, DATA), index), T, arg) \
) \
{ \
BOOST_PP_TUPLE_ELEM(3, 2, DATA) obj.BOOST_PP_TUPLE_ELEM(3, 0, DATA)( \
BOOST_PP_ENUM_PARAMS( \
BOOST_PP_ADD(BOOST_PP_TUPLE_ELEM(3, 1, DATA), index), arg \
BOOST_PP_ADD_D(1, BOOST_PP_TUPLE_ELEM(3, 1, DATA), index), arg \
) \
); \
}
@@ -113,8 +114,8 @@ struct func_stubs_base {};
template <typename SigT> \
struct gen { \
\
typedef typename boost::python::detail::type_at<0, SigT>::type RT; \
typedef typename boost::python::detail::type_at<1, SigT>::type ClassT; \
typedef typename ::boost::mpl::front<SigT>::type RT; \
typedef typename ::boost::mpl::at_c<1, SigT>::type ClassT; \
\
BOOST_PP_REPEAT_2ND \
( \
@@ -127,7 +128,7 @@ struct func_stubs_base {};
( \
BOOST_PP_INC(N_DFLTS), \
BPL_IMPL_MEM_FUNC_WRAPPER_GEN, \
(FNAME, BOOST_PP_SUB(N_ARGS, N_DFLTS), RETURN) \
(FNAME, BOOST_PP_SUB_D(1, N_ARGS, N_DFLTS), RETURN) \
) \
}; \
};
@@ -224,11 +225,11 @@ struct func_stubs_base {};
// template <typename SigT>
// struct gen {
//
// typedef typename mpl::at_c<0, SigT>::type RT;
// typedef typename mpl::at_c<1, SigT>::type T0;
// typedef typename mpl::at_c<2, SigT>::type T1;
// typedef typename mpl::at_c<3, SigT>::type T2;
// typedef typename mpl::at_c<4, SigT>::type T3;
// typedef typename ::boost::mpl::at_c<0, SigT>::type RT;
// typedef typename ::boost::mpl::at_c<1, SigT>::type T0;
// typedef typename ::boost::mpl::at_c<2, SigT>::type T1;
// typedef typename ::boost::mpl::at_c<3, SigT>::type T2;
// typedef typename ::boost::mpl::at_c<4, SigT>::type T3;
//
// static RT func_0(T0 arg0)
// { return foo(arg0); }
@@ -265,7 +266,7 @@ struct func_stubs_base {};
FNAME, \
GENERATOR_NAME, \
MAX_ARGS, \
BOOST_PP_SUB(MAX_ARGS, MIN_ARGS) \
BOOST_PP_SUB_D(1, MAX_ARGS, MIN_ARGS) \
)
#define BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(GENERATOR_NAME, FNAME, MIN_ARGS, MAX_ARGS) \
@@ -274,7 +275,7 @@ struct func_stubs_base {};
FNAME, \
GENERATOR_NAME, \
MAX_ARGS, \
BOOST_PP_SUB(MAX_ARGS, MIN_ARGS) \
BOOST_PP_SUB_D(1, MAX_ARGS, MIN_ARGS) \
)
// deprecated macro names (to be removed)

View File

@@ -68,7 +68,13 @@ inline void destroy_referent_impl(void* p, T& (*)())
// must come *before* T for metrowerks
value_destroyer<
(boost::is_array<T>::value)
, (boost::has_trivial_destructor<T>::value)
,
// Aleksey, this shouldn't be needed
# if !defined(BOOST_MSVC) || BOOST_MSVC > 1200
(boost::has_trivial_destructor<T>::value)
# else
false
# endif
>::execute((const volatile T*)p);
}

View File

@@ -22,7 +22,7 @@
make_tuple(BOOST_PYTHON_BINARY_ENUM(N, A, const& a))
{
tuple result((detail::new_reference)::PyTuple_New(N));
BOOST_PP_REPEAT(N, BOOST_PYTHON_MAKE_TUPLE_ARG, _)
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_MAKE_TUPLE_ARG, _)
return result;
}

View File

@@ -27,12 +27,11 @@
# endif
# ifndef BOOST_PYTHON_MAX_ARITY
# define BOOST_PYTHON_MAX_ARITY 10 // 15
# define BOOST_PYTHON_MAX_ARITY 15
# endif
// Temporary!
# ifndef BOOST_MPL_LIMIT_LIST_SIZE
# define BOOST_MPL_LIMIT_LIST_SIZE BOOST_PYTHON_MAX_ARITY
# ifndef BOOST_PYTHON_MAX_BASES
# define BOOST_PYTHON_MAX_BASES 10
# endif
# define BOOST_PYTHON_CV_QUALIFIER(i) \

View File

@@ -96,7 +96,7 @@ struct returning<void>
, PyObject*, P const* policies)
{
// check that each of the arguments is convertible
BOOST_PP_REPEAT(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
// find the result converter
typedef typename P::result_converter result_converter;
@@ -104,7 +104,7 @@ struct returning<void>
if (!cr.convertible() || !policies->precall(args_))
return 0;
PyObject* result = cr(
(*pf)(BOOST_PP_REPEAT(N, BOOST_PYTHON_CALL_ARGS, nil))
(*pf)(BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_CALL_ARGS, nil))
);
return policies->postcall(args_, result);
}
@@ -117,11 +117,11 @@ struct returning<void>
, PyObject*, P const* policies)
{
// check that each of the arguments is convertible
BOOST_PP_REPEAT(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
if (!policies->precall(args_))
return 0;
(*pf)(BOOST_PP_REPEAT(N, BOOST_PYTHON_CALL_ARGS, nil));
(*pf)(BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_CALL_ARGS, nil));
return policies->postcall(args_, detail::none());
}
# endif // returning void / non-void
@@ -168,7 +168,7 @@ struct returning<void>
return 0;
// unroll a loop for the rest of them
BOOST_PP_REPEAT(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
// find the result converter
typedef typename P::result_converter result_converter;
@@ -177,7 +177,7 @@ struct returning<void>
return 0;
PyObject* result = cr(
((ct(PyTuple_GET_ITEM(args_, 0))).*pmf)(
BOOST_PP_REPEAT(N, BOOST_PYTHON_CALL_ARGS, nil))
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_CALL_ARGS, nil))
);
return policies->postcall(args_, result);
}
@@ -196,13 +196,13 @@ struct returning<void>
return 0;
// unroll a loop for the rest of them
BOOST_PP_REPEAT(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
if (!policies->precall(args_))
return 0;
((ct(PyTuple_GET_ITEM(args_, 0))).*pmf)(
BOOST_PP_REPEAT(N, BOOST_PYTHON_CALL_ARGS, nil));
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_CALL_ARGS, nil));
return policies->postcall(args_, detail::none());
}
# endif

View File

@@ -3,14 +3,38 @@
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef TYPE_LIST_DWA200222_HPP
# define TYPE_LIST_DWA200222_HPP
# include <boost/mpl/list.hpp>
#ifndef TYPE_LIST_DWA2002913_HPP
# define TYPE_LIST_DWA2002913_HPP
namespace boost { namespace python { namespace detail {
# include <boost/config.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/arithmetic/inc.hpp>
struct empty_list : boost::mpl::list<>::type {};
# if BOOST_PYTHON_MAX_ARITY + 2 > BOOST_PYTHON_MAX_BASES
# define BOOST_PYTHON_LIST_SIZE BOOST_PP_INC(BOOST_PP_INC(BOOST_PYTHON_MAX_ARITY))
# else
# define BOOST_PYTHON_BASE_LIST_SIZE BOOST_PYTHON_MAX_BASES
# endif
}}} // namespace boost::python::detail
// Compute the MPL list header to use for lists up to BOOST_PYTHON_LIST_SIZE in length
# if BOOST_PYTHON_LIST_SIZE > 48
# error Arities above 48 not supported by Boost.Python due to MPL internal limit
# elif BOOST_PYTHON_LIST_SIZE > 38
# include <boost/mpl/list/list50.hpp>
# elif BOOST_PYTHON_LIST_SIZE > 28
# include <boost/mpl/list/list40.hpp>
# elif BOOST_PYTHON_LIST_SIZE > 18
# include <boost/mpl/list/list30.hpp>
# elif BOOST_PYTHON_LIST_SIZE > 8
# include <boost/mpl/list/list20.hpp>
# else
# include <boost/mpl/list/list10.hpp>
# endif
#endif // TYPE_LIST_DWA200222_HPP
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
# include <boost/python/detail/type_list_impl.hpp>
# else
# include <boost/python/detail/type_list_impl_no_pts.hpp>
# endif
#endif // TYPE_LIST_DWA2002913_HPP

View File

@@ -0,0 +1,55 @@
#ifndef BOOST_PP_IS_ITERATING
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
# ifndef TYPE_LIST_IMPL_DWA2002913_HPP
# define TYPE_LIST_IMPL_DWA2002913_HPP
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/enum_params_with_a_default.hpp>
# include <boost/preprocessor/repetition/enum.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/arithmetic/sub.hpp>
# include <boost/preprocessor/iterate.hpp>
namespace boost { namespace python { namespace detail {
template <BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_LIST_SIZE, class T, mpl::void_)>
struct type_list
: BOOST_PP_CAT(mpl::list,BOOST_PYTHON_LIST_SIZE)<BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE, T)>
{
};
# define BOOST_PP_ITERATION_PARAMS_1 \
(3, (0, BOOST_PP_DEC(BOOST_PYTHON_LIST_SIZE), <boost/python/detail/type_list_impl.hpp>))
# include BOOST_PP_ITERATE()
}}} // namespace boost::python::detail
# endif // TYPE_LIST_IMPL_DWA2002913_HPP
#else // BOOST_PP_IS_ITERATING
# define N BOOST_PP_ITERATION()
# define BOOST_PYTHON_VOID_ARGS BOOST_PP_SUB_D(1,BOOST_PYTHON_LIST_SIZE,N)
template <
BOOST_PP_ENUM_PARAMS(N, class T)
>
struct type_list<
BOOST_PP_ENUM_PARAMS(N, T)
BOOST_PP_COMMA_IF(N)
BOOST_PP_ENUM(
BOOST_PYTHON_VOID_ARGS, BOOST_PYTHON_FIXED, mpl::void_)
>
: BOOST_PP_CAT(mpl::list,N)<BOOST_PP_ENUM_PARAMS(N, T)>
{
};
# undef BOOST_PYTHON_VOID_ARGS
# undef N
#endif // BOOST_PP_IS_ITERATING

View File

@@ -0,0 +1,101 @@
#ifndef BOOST_PP_IS_ITERATING
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
# ifndef TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP
# define TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/enum_params_with_a_default.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/empty.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/mpl/void.hpp>
namespace boost { namespace python { namespace detail {
template< typename T >
struct is_list_arg
{
enum { value = true };
};
template<>
struct is_list_arg<mpl::void_>
{
enum { value = false };
};
template<int> struct type_list_impl_chooser;
# define BOOST_PP_ITERATION_PARAMS_1 \
(3, (0, BOOST_PYTHON_LIST_SIZE, <boost/python/detail/type_list_impl_no_pts.hpp>))
# include BOOST_PP_ITERATE()
# define BOOST_PYTHON_PLUS() +
# define BOOST_PYTHON_IS_LIST_ARG(z, n, data) \
BOOST_PP_IF(n, BOOST_PYTHON_PLUS, BOOST_PP_EMPTY)() \
is_list_arg< BOOST_PP_CAT(T,n) >::value
template<
BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE, class T)
>
struct type_list_count_args
{
enum { value =
BOOST_PP_REPEAT_1(BOOST_PYTHON_LIST_SIZE, BOOST_PYTHON_IS_LIST_ARG, _)
};
};
# undef BOOST_PYTHON_IS_LIST_ARG
# undef BOOST_PYTHON_PLUS
template<
BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE, class T)
>
struct type_list_impl
{
typedef type_list_count_args< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE,T) > arg_num_;
typedef typename detail::type_list_impl_chooser< arg_num_::value >
::template result_< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE,T) >::type type;
};
template<
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_LIST_SIZE, class T, mpl::void_)
>
struct type_list
: detail::type_list_impl< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE,T) >::type
{
typedef typename detail::type_list_impl<
BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE,T)
>::type type;
};
}}} // namespace boost::python::detail
# endif // TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP
#else // BOOST_PP_IS_ITERATING
# define N BOOST_PP_ITERATION()
template<>
struct type_list_impl_chooser<N>
{
template<
BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE, class T)
>
struct result_
{
typedef BOOST_PP_CAT(mpl::list,N)<
BOOST_PP_ENUM_PARAMS(N, T)
> type;
};
};
# undef N
#endif // BOOST_PP_IS_ITERATING

View File

@@ -1,116 +1,28 @@
///////////////////////////////////////////////////////////////////////////////
//
#error obsolete
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
//
///////////////////////////////////////////////////////////////////////////////
#if !defined(BOOST_PP_IS_ITERATING)
#ifndef TYPE_LIST_UTILS_JDG20020826_HPP
#define TYPE_LIST_UTILS_JDG20020826_HPP
# define TYPE_LIST_UTILS_JDG20020826_HPP
# include <boost/mpl/at.hpp>
# include <boost/mpl/size.hpp>
//# include <boost/mpl/pop_front.hpp>
//# include <boost/mpl/pop_back.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/enum_shifted_params.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/dec.hpp>
# include <boost/preprocessor/debug/line.hpp>
# include <boost/mpl/list.hpp>
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace boost { namespace python { namespace detail {
# if (!defined(__EDG_VERSION__) || __EDG_VERSION__ > 245) \
&& (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600)
template< typename T >
struct is_list_arg
{
enum { value = true };
};
template <int N, class L>
struct type_at : mpl::at_c<N, L> {};
template <class L>
struct type_list_size : boost::mpl::size<L> {};
// template <class L>
// struct pop_front : public boost::mpl::pop_front<L> {};
//
// template <class L>
// struct pop_back : public boost::mpl::pop_back<L> {};
# else
template <int N, class L>
struct type_at {};
template <class L>
struct type_list_size {};
// template <class L>
// struct pop_front {};
//
// template <class L>
// struct pop_back {};
// template <class L, class T>
// struct push_back {};
# define BOOST_PP_ITERATION_PARAMS_1 \
(3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/type_list_utils.hpp>))
# include BOOST_PP_ITERATE()
# endif
}}} // namespace boost::python::detail
template<>
struct is_list_arg<mpl::void_>
{
enum { value = false };
};
}}}
# endif
#endif // TYPE_LIST_UTILS_JDG20020826_HPP
#else // defined(BOOST_PP_IS_ITERATING)
# define N BOOST_PP_ITERATION()
# if (N < BOOST_PYTHON_MAX_ARITY-1)
template <BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_ARITY, class A)>
struct type_at<N, mpl::list<BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_ARITY, A)> >
{
typedef BOOST_PP_CAT(A, N) type;
};
// template <BOOST_PP_ENUM_PARAMS(N, class A) BOOST_PP_COMMA_IF(N) class T>
// struct push_back<mpl::list<BOOST_PP_ENUM_PARAMS(N, A)>, T>
// {
// typedef mpl::list<BOOST_PP_ENUM_PARAMS(N, A) BOOST_PP_COMMA_IF(N) T> sequence;
// };
# if (N > 0)
// template <BOOST_PP_ENUM_PARAMS(N, class A)>
// struct pop_front<mpl::list<BOOST_PP_ENUM_PARAMS(N, A)> >
// {
// typedef mpl::list<BOOST_PP_ENUM_SHIFTED_PARAMS(N, A)> sequence;
// };
//
// template <BOOST_PP_ENUM_PARAMS(N, class A)>
// struct pop_back<mpl::list<BOOST_PP_ENUM_PARAMS(N, A)> >
// {
// typedef mpl::list<BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), A)> sequence;
// };
# endif
# endif
template <BOOST_PP_ENUM_PARAMS(N, class A)>
struct type_list_size<mpl::list<BOOST_PP_ENUM_PARAMS(N, A)> >
{
BOOST_STATIC_CONSTANT(long, value = N);
};
# undef N
#endif // !defined(BOOST_PP_IS_ITERATING)

View File

@@ -115,7 +115,11 @@ typedef int pid_t;
#endif // _WIN32
#include <Python.h>
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2 && PY_MICRO_VERSION < 2
# include <boost/python/detail/python22_fixed.h>
#else
# include <Python.h>
#endif
#ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED
# undef ULONG_MAX

View File

@@ -15,6 +15,8 @@ namespace boost { namespace python {
template <class T>
struct enum_ : public objects::enum_base
{
typedef objects::enum_base base;
enum_(char const* name);
inline enum_<T>& value(char const* name, T);
@@ -26,7 +28,7 @@ struct enum_ : public objects::enum_base
template <class T>
inline enum_<T>::enum_(char const* name)
: enum_base(
: base(
name
, &enum_<T>::to_python
, &enum_<T>::convertible
@@ -39,7 +41,7 @@ inline enum_<T>::enum_(char const* name)
template <class T>
PyObject* enum_<T>::to_python(void const* x)
{
return enum_base::to_python(
return base::to_python(
converter::registered<T>::converters.class_object
, static_cast<long>(*(T const*)x));
}

View File

@@ -10,7 +10,7 @@
#ifndef INIT_JDG20020820_HPP
#define INIT_JDG20020820_HPP
#include <boost/mpl/list.hpp>
#include <boost/python/detail/type_list.hpp>
#include <boost/mpl/fold_backward.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/apply_if.hpp>
@@ -31,6 +31,8 @@
#include <boost/static_assert.hpp>
#include <boost/preprocessor/enum_params_with_a_default.hpp>
#include <boost/preprocessor/enum_params.hpp>
#include <boost/preprocessor/enum_params.hpp>
#include <boost/preprocessor/repeat.hpp>
///////////////////////////////////////////////////////////////////////////////
#define BOOST_PYTHON_TEMPLATE_TYPES_WITH_DEFAULT \
@@ -125,7 +127,7 @@ namespace detail {
template <BOOST_PYTHON_TEMPLATE_TYPES>
struct init //: detail::check_init_params<BOOST_PYTHON_TEMPLATE_ARGS>
{
typedef mpl::list<BOOST_PYTHON_TEMPLATE_ARGS> signature_;
typedef detail::type_list<BOOST_PYTHON_TEMPLATE_ARGS> signature_;
typedef typename mpl::end<signature_>::type finish;
// Find the optional<> element, if any
@@ -144,7 +146,7 @@ struct init //: detail::check_init_params<BOOST_PYTHON_TEMPLATE_ARGS>
typedef typename mpl::apply_if<
is_same<opt,finish>
, mpl::list<>
, mpl::list0<>
, opt
>::type optional_args;
@@ -159,7 +161,7 @@ struct init //: detail::check_init_params<BOOST_PYTHON_TEMPLATE_ARGS>
// Build a reverse image of all the args, including optionals
typedef typename mpl::fold<
required_args
, mpl::list<>
, mpl::list0<>
, mpl::push_front<mpl::_1, mpl::_2>
>::type reversed_required;
@@ -182,7 +184,7 @@ struct init //: detail::check_init_params<BOOST_PYTHON_TEMPLATE_ARGS>
///////////////////////////////////////////////////////////////////////////////
template <BOOST_PYTHON_TEMPLATE_TYPES>
struct optional
: mpl::list<BOOST_PYTHON_TEMPLATE_ARGS>
: detail::type_list<BOOST_PYTHON_TEMPLATE_ARGS>
{
};
@@ -193,7 +195,7 @@ namespace detail
{
typedef typename mpl::fold<
ReversedArgs
, mpl::list<>
, mpl::list0<>
, mpl::push_front<mpl::_1,mpl::_2>
>::type args;

View File

@@ -42,7 +42,8 @@ struct additional_instance_size
typedef instance<Data> instance_data;
typedef instance<char> instance_char;
BOOST_STATIC_CONSTANT(
std::size_t, value = sizeof(instance_data) - offsetof(instance_char,storage));
std::size_t, value = sizeof(instance_data)
- BOOST_PYTHON_OFFSETOF(instance_char,storage));
};
}}} // namespace boost::python::object

View File

@@ -15,7 +15,9 @@
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/at.hpp>
# include <boost/mpl/next.hpp>
# include <boost/mpl/begin_end.hpp>
# include <boost/mpl/apply.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
@@ -28,9 +30,18 @@ namespace boost { namespace python { namespace objects {
template <int nargs> struct make_holder;
// Temporary workaround for vc6 bug. Hopefully Aleksey will work
// around it in the MPL source somehow... is this an example of ETI?
template <class T> struct delay
{
typedef typename T::type type;
};
# define BOOST_PYTHON_FORWARD_ARG(z, index, _) \
typedef typename mpl::at_c<index,ArgList>::type t##index; \
typedef typename forward<t##index>::type f##index;
typedef typename iter##index::type t##index; \
typedef typename forward<t##index>::type f##index; \
typedef typename mpl::next<iter##index>::type \
BOOST_PP_CAT(iter,BOOST_PP_INC(index));
# define BOOST_PYTHON_DO_FORWARD_ARG(z, index, _) , f##index(a##index)
@@ -56,7 +67,8 @@ struct make_holder<N>
template <class Holder, class ArgList>
struct apply
{
BOOST_PP_REPEAT(N, BOOST_PYTHON_FORWARD_ARG, nil)
typedef typename delay<mpl::begin<ArgList> >::type iter0;
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))
@@ -66,7 +78,7 @@ struct make_holder<N>
void* memory = Holder::allocate(p, offsetof(instance_t, storage), sizeof(Holder));
try {
(new (memory) Holder(
p BOOST_PP_REPEAT(N, BOOST_PYTHON_DO_FORWARD_ARG, nil)))->install(p);
p BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_DO_FORWARD_ARG, nil)))->install(p);
}
catch(...) {
Holder::deallocate(p, memory);

View File

@@ -131,7 +131,7 @@ void* pointer_holder_back_reference<Pointer, Value>::holds(type_info dst_t)
# endif
pointer_holder(PyObject* BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, a))
: m_p(new Value(
BOOST_PP_REPEAT(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
))
{}
@@ -149,7 +149,7 @@ void* pointer_holder_back_reference<Pointer, Value>::holds(type_info dst_t)
pointer_holder_back_reference(
PyObject* p BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, a))
: m_p(new held_type(
p BOOST_PP_COMMA_IF(N) BOOST_PP_REPEAT(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
p BOOST_PP_COMMA_IF(N) BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
))
{}

View File

@@ -101,7 +101,7 @@ void* value_holder_back_reference<Held,BackReferenceType>::holds(
value_holder(
PyObject* BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, a))
: m_held(
BOOST_PP_REPEAT(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
)
{}
@@ -121,7 +121,7 @@ void* value_holder_back_reference<Held,BackReferenceType>::holds(
PyObject* p BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, a))
: m_held(
p BOOST_PP_COMMA_IF(N)
BOOST_PP_REPEAT(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
)
{
}

View File

@@ -180,7 +180,7 @@ namespace api
// there is a confirmed CWPro8 codegen bug here. We prevent the
// early destruction of a temporary by binding a named object
// instead.
# if __MWERKS__ < 0x3000 || __MWERKS__ > 0x3001
# if __MWERKS__ < 0x3000 || __MWERKS__ > 0x3002
typedef object const& object_cref2;
# else
typedef object const object_cref2;

View File

@@ -19,8 +19,19 @@
# include <boost/preprocessor/empty.hpp>
# include <boost/preprocessor/arithmetic/sub.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/mpl/list.hpp>
# include <boost/python/detail/type_list.hpp>
# include <boost/preprocessor/debug/line.hpp>
# include <boost/preprocessor/arithmetic/sub.hpp>
# include <boost/preprocessor/arithmetic/inc.hpp>
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
# define BOOST_PYTHON_FUNCTION_SIGNATURE_LIST(n) \
BOOST_PP_CAT(mpl::list, BOOST_PP_INC(n))
# define BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST(n) \
BOOST_PP_CAT(mpl::list, BOOST_PP_INC(BOOST_PP_INC(n)))
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace python { namespace detail {
@@ -65,6 +76,10 @@ namespace boost { namespace python { namespace detail {
}} // namespace boost::python
# undef BOOST_PYTHON_FUNCTION_SIGNATURE_LIST
# undef BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST
///////////////////////////////////////////////////////////////////////////////
# endif // SIGNATURE_JDG20020813_HPP
@@ -73,47 +88,38 @@ namespace boost { namespace python { namespace detail {
# define N BOOST_PP_ITERATION()
template <
class RT BOOST_PP_COMMA_IF(N)
BOOST_PYTHON_UNARY_ENUM(N, class T)>
inline mpl::list<
RT BOOST_PP_COMMA_IF(N)
BOOST_PP_ENUM_PARAMS(N, T)>
class RT BOOST_PP_ENUM_TRAILING_PARAMS(N, class T)>
inline BOOST_PYTHON_FUNCTION_SIGNATURE_LIST(N)<
RT BOOST_PP_ENUM_TRAILING_PARAMS(N, T)>
get_signature(RT(*)(BOOST_PP_ENUM_PARAMS(N, T)))
{
return mpl::list<
RT BOOST_PP_COMMA_IF(N)
BOOST_PP_ENUM_PARAMS(N, T)>();
return BOOST_PYTHON_FUNCTION_SIGNATURE_LIST(N)<
RT BOOST_PP_ENUM_TRAILING_PARAMS(N, T)
>();
}
///////////////////////////////////////////////////////////////////////////////
#if N <= (BOOST_PYTHON_MAX_ARITY - 2)
template <
class RT, class ClassT BOOST_PP_COMMA_IF(N)
BOOST_PYTHON_UNARY_ENUM(N, class T)>
inline mpl::list<
RT, ClassT BOOST_PP_COMMA_IF(N)
BOOST_PP_ENUM_PARAMS(N, T)>
class RT, class ClassT BOOST_PP_ENUM_TRAILING_PARAMS(N, class T)>
inline BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST(N)<
RT, ClassT BOOST_PP_ENUM_TRAILING_PARAMS(N, T)>
get_signature(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T)))
{
return mpl::list<
RT, ClassT BOOST_PP_COMMA_IF(N)
BOOST_PP_ENUM_PARAMS(N, T)>();
return BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST(N)<
RT, ClassT BOOST_PP_ENUM_TRAILING_PARAMS(N, T)>();
}
///////////////////////////////////////
template <
class RT, class ClassT BOOST_PP_COMMA_IF(N)
BOOST_PYTHON_UNARY_ENUM(N, class T)>
inline mpl::list<
RT, ClassT const BOOST_PP_COMMA_IF(N)
BOOST_PP_ENUM_PARAMS(N, T)>
class RT, class ClassT BOOST_PP_ENUM_TRAILING_PARAMS(N, class T)>
inline BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST(N)<
RT, ClassT const BOOST_PP_ENUM_TRAILING_PARAMS(N, T)>
get_signature(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T)) const)
{
return mpl::list<
RT, ClassT const
BOOST_PP_COMMA_IF(N)
BOOST_PP_ENUM_PARAMS(N, T)>();
return BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST(N)<
RT, ClassT const BOOST_PP_ENUM_TRAILING_PARAMS(N, T)>();
}
#endif // N < (BOOST_PYTHON_MAX_ARITY - 2)