2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 06:02:14 +00:00

Use Paul M's preprocessor iteration

[SVN r14384]
This commit is contained in:
Dave Abrahams
2002-07-09 19:35:48 +00:00
parent 6cb4fbb1c4
commit 931aab22bb
19 changed files with 963 additions and 709 deletions

View File

@@ -1,3 +1,5 @@
#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
@@ -5,33 +7,35 @@
// to its suitability for any purpose.
#ifndef ARGS_DWA2002323_HPP
# define ARGS_DWA2002323_HPP
# include <boost/config.hpp>
# include <boost/mpl/type_list.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/enum_params_with_a_default.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/config.hpp>
# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245
namespace boost { namespace python {
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/type_list.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/iterate.hpp>
# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245
namespace boost { namespace python {
// A type list for specifying arguments
template < BOOST_MPL_LIST_DEFAULT_PARAMETERS(typename A, boost::mpl::null_argument) >
struct args : boost::mpl::type_list< BOOST_MPL_LIST_PARAMETERS(A) >::type
template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, boost::mpl::null_argument) >
struct args : boost::mpl::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<>. Eventually, however, inheritance from mpl::list
// *should* be eliminated and the two versions unified, just in
// order to get true arity independence
# else // slow template instantiators need this other version with
// explicit specializations of mpl::size<> and
// mpl::at<>. 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 {
namespace boost { namespace python {
template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_MAX_ARITY, class A, boost::mpl::null_argument) >
template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, boost::mpl::null_argument) >
struct args
{};
@@ -42,32 +46,45 @@ namespace boost { namespace mpl {
template <class T> struct size;
template <long N, class Seq> struct at;
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/args.hpp>
# endif
# define BOOST_PP_ITERATION_PARAMS_1 4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/args.hpp>, 1)
# include BOOST_PP_ITERATE()
# define BOOST_PYTHON_ARGS_SIZE(index,ignored) \
template <BOOST_PP_ENUM_PARAMS(index, class A)> \
struct size<boost::python::args<BOOST_PP_ENUM_PARAMS(index, A)> > \
{ \
BOOST_STATIC_CONSTANT(long, value = index); \
}; \
# define BOOST_PP_ITERATION_PARAMS_1 4, (0, BOOST_PYTHON_MAX_ARITY - 1, <boost/python/args.hpp>, 2)
# include BOOST_PP_ITERATE()
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_ARGS_SIZE, nil)
# define BOOST_PYTHON_ARGS_AT(index,ignored) \
template < \
BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH), class A)> \
struct at<index, boost::python::args< \
BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH), A)> > \
{ \
typedef BOOST_PP_CAT(A,index) type; \
}; \
BOOST_PP_REPEAT_FROM_TO_2ND(
BOOST_PP_DEC(BOOST_PYTHON_ARITY_START), BOOST_PP_DEC(BOOST_PYTHON_ARITY_FINISH)
, BOOST_PYTHON_ARGS_AT, data)
}}
# endif
#endif // ARGS_DWA2002323_HPP
}} // 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 ---------- */
#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<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

@@ -1,51 +1,63 @@
#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
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CALL_DWA2002411_HPP
# define CALL_DWA2002411_HPP
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/converter/return_from_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/enum.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/python/detail/void_return.hpp>
# include <boost/type.hpp>
# ifndef CALL_DWA2002411_HPP
# define CALL_DWA2002411_HPP
namespace boost { namespace python {
# include <boost/type.hpp>
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/call.hpp>
# endif
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/converter/return_from_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/python/detail/void_return.hpp>
# define BOOST_PYTHON_CALL_FUNCTION(nargs,ignored) \
template < \
class R \
BOOST_PP_COMMA_IF(nargs) BOOST_PP_ENUM_PARAMS(nargs, class A) \
> \
typename detail::returnable<R>::type \
call(PyObject* callable \
BOOST_PP_COMMA_IF(nargs) BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,const& a)) \
, boost::type<R>* = 0 \
) \
{ \
converter::return_from_python<R> converter; \
return converter( \
PyEval_CallFunction( \
callable \
, const_cast<char*>(BOOST_PYTHON_ARG_STRING(nargs)) \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs,BOOST_PYTHON_ARG_TO_PYTHON_GET,nil) \
)); \
}
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/repeat.hpp>
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CALL_FUNCTION,data)
namespace boost { namespace python {
# define BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET(n, _) \
, converter::arg_to_python<A##n>(a##n).get()
# define BOOST_PP_ITERATION_PARAMS_1 3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/call.hpp>)
# include BOOST_PP_ITERATE()
# undef BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET
}} // namespace boost::python
#endif // CALL_DWA2002411_HPP
# endif // CALL_DWA2002411_HPP
#elif BOOST_PP_ITERATION_DEPTH() == 1
# line BOOST_PP_LINE(__LINE__, call.hpp)
# define N BOOST_PP_ITERATION()
template <
class R
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
>
typename detail::returnable<R>::type
call(PyObject* callable
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, const& a)
, boost::type<R>* = 0
)
{
converter::return_from_python<R> converter;
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)
));
}
# undef N
#endif

View File

@@ -1,52 +1,63 @@
#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
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef CALL_METHOD_DWA2002411_HPP
# define CALL_METHOD_DWA2002411_HPP
# ifndef CALL_METHOD_DWA2002411_HPP
# define CALL_METHOD_DWA2002411_HPP
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/converter/return_from_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/enum.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/python/detail/void_return.hpp>
# include <boost/type.hpp>
# include <boost/type.hpp>
namespace boost { namespace python {
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/converter/return_from_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/python/detail/void_return.hpp>
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/call_method.hpp>
# endif
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/repeat.hpp>
# define BOOST_PYTHON_CALL_METHOD_FUNCTION(nargs,ignored) \
template < \
class R \
BOOST_PP_COMMA_IF(nargs) BOOST_PP_ENUM_PARAMS(nargs, class A) \
> \
typename detail::returnable<R>::type \
call_method(PyObject* self, char const* name \
BOOST_PP_COMMA_IF(nargs) BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,const& a)) \
, boost::type<R>* = 0 \
) \
{ \
converter::return_from_python<R> converter; \
return converter( \
PyEval_CallMethod( \
self \
, const_cast<char*>(name) \
, const_cast<char*>(BOOST_PYTHON_ARG_STRING(nargs)) \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs,BOOST_PYTHON_ARG_TO_PYTHON_GET,nil) \
)); \
}
namespace boost { namespace python {
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CALL_METHOD_FUNCTION,data)
# define BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET(n, _) \
, converter::arg_to_python<A##n>(a##n).get()
# define BOOST_PP_ITERATION_PARAMS_1 3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/call_method.hpp>)
# include BOOST_PP_ITERATE()
# undef BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET
}} // namespace boost::python
#endif // CALL_METHOD_DWA2002411_HPP
# endif // CALL_METHOD_DWA2002411_HPP
#elif BOOST_PP_ITERATION_DEPTH() == 1
# line BOOST_PP_LINE(__LINE__, call_method.hpp)
# define N BOOST_PP_ITERATION()
template <
class R
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
>
typename detail::returnable<R>::type
call_method(PyObject* self, char const* name
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, A, const& a)
, boost::type<R>* = 0
)
{
converter::return_from_python<R> converter;
return converter(
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)
));
}
# undef N
#endif // BOOST_PP_IS_ITERATING

View File

@@ -0,0 +1,15 @@
// 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 CONVERTIBLE_FUNCTION_DWA200278_HPP
# define CONVERTIBLE_FUNCTION_DWA200278_HPP
namespace boost { namespace python { namespace converter {
typedef void* (*convertible_function)(PyObject*);
}}} // namespace boost::python::converter
#endif // CONVERTIBLE_FUNCTION_DWA200278_HPP

View File

@@ -6,19 +6,20 @@
#ifndef REGISTRATIONS_DWA2002223_HPP
# define REGISTRATIONS_DWA2002223_HPP
# include <boost/python/converter/convertible_function.hpp>
# include <boost/python/converter/constructor_function.hpp>
namespace boost { namespace python { namespace converter {
struct lvalue_from_python_registration
{
void* (*convert)(PyObject* source);
convertible_function convert;
lvalue_from_python_registration* next;
};
struct rvalue_from_python_registration
{
void* (*convertible)(PyObject*);
convertible_function convertible;
constructor_function construct;
rvalue_from_python_registration* next;
};

View File

@@ -11,6 +11,7 @@
# include <boost/python/converter/to_python_function_type.hpp>
# include <boost/python/converter/rvalue_from_python_data.hpp>
# include <boost/python/converter/constructor_function.hpp>
# include <boost/python/converter/convertible_function.hpp>
namespace boost { namespace python { namespace converter {
@@ -33,7 +34,7 @@ namespace registry
// Insert an rvalue from_python converter
BOOST_PYTHON_DECL void insert(
void* (*convertible)(PyObject*)
convertible_function
, constructor_function
, type_info
);
@@ -41,7 +42,7 @@ namespace registry
// Insert an rvalue from_python converter at the tail of the
// chain. Used for implicit conversions
BOOST_PYTHON_DECL void push_back(
void* (*convertible)(PyObject*)
convertible_function
, constructor_function
, type_info
);

View File

@@ -1,3 +1,5 @@
#if !defined(BOOST_PP_IS_ITERATING)
// (C) Copyright David Abrahams 2001. 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
@@ -9,13 +11,15 @@
// functions by gen_arg_tuple_size.python
#ifndef ARG_TUPLE_SIZE_DWA20011201_HPP
# define ARG_TUPLE_SIZE_DWA20011201_HPP
# define ARG_TUPLE_SIZE_DWA20011201_HPP
# include <boost/config.hpp>
# include <boost/python/detail/char_array.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/aux_/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
namespace boost { namespace python { namespace detail {
@@ -24,31 +28,6 @@ namespace boost { namespace python { namespace detail {
// (member) function of the given type.
template <class F> struct arg_tuple_size;
// Include the pre-expanded version of the code
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/arg_tuple_size.hpp>
# endif
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
// Specializations for function pointers
# define BOOST_PYTHON_ARG_TUPLE_SIZE_PF(args, ignored) \
template <class R BOOST_PP_COMMA_IF(args) BOOST_MPL_TEMPLATE_PARAMETERS(0, args, class A)> \
struct arg_tuple_size<BOOST_PYTHON_FN(*,0,args)> \
{ \
BOOST_STATIC_CONSTANT(std::size_t, value = args); \
};
// Specializations for member function pointers
# define BOOST_PYTHON_ARG_TUPLE_SIZE_PMF(args, cv) \
template <class R, BOOST_MPL_TEMPLATE_PARAMETERS(0, args, class A)> \
struct arg_tuple_size<BOOST_PYTHON_FN(A0::*,1,args) cv()> \
{ \
BOOST_STATIC_CONSTANT(std::size_t, value = args); \
};
# else
// We will use the "sizeof() trick" to work around the lack of
// partial specialization in MSVC6 and its broken-ness in borland.
// See http://opensource.adobe.com or
@@ -60,31 +39,88 @@ struct arg_tuple_size<BOOST_PYTHON_FN(A0::*,1,args) cv()> \
// their return value is used to discriminate between various free
// and member function pointers at compile-time.
# define BOOST_PYTHON_ARG_TUPLE_SIZE_PF(args, ignored) \
template <class R BOOST_PP_COMMA_IF(args) BOOST_MPL_TEMPLATE_PARAMETERS(0, args, class A)> \
char_array<args> arg_tuple_size_helper(BOOST_PYTHON_FN(*,0,args));
// Specializations for function pointers
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/arg_tuple_size.hpp>, BOOST_PYTHON_FUNCTION_POINTER)
# include BOOST_PP_ITERATE()
# define BOOST_PYTHON_ARG_TUPLE_SIZE_PMF(args, cv) \
template <class R, BOOST_MPL_TEMPLATE_PARAMETERS(0, args, class A)> \
char_array<args> arg_tuple_size_helper(BOOST_PYTHON_FN(A0::*,1,args)cv());
# endif
// Specializations for member function pointers
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, BOOST_PYTHON_CV_COUNT - 1, <boost/python/detail/arg_tuple_size.hpp>, BOOST_PYTHON_POINTER_TO_MEMBER)
# include BOOST_PP_ITERATE()
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_ARG_TUPLE_SIZE_PF, nil)
// Generate a series for each cv-qualification
BOOST_PYTHON_REPEAT_MF_CV_2ND(BOOST_PYTHON_ARG_TUPLE_SIZE_PMF)
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(__BORLANDC__)
template <class F>
struct arg_tuple_size
{
// The sizeof() magic happens here
BOOST_STATIC_CONSTANT(std::size_t, value
= sizeof(arg_tuple_size_helper(F(0)).elements) - 1);
= sizeof(arg_tuple_size_helper(F(0)).elements) - 1);
};
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
}}} // namespace boost::python::detail
#endif // ARG_TUPLE_SIZE_DWA20011201_HPP
// --------------- function pointers --------------- //
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
# line BOOST_PP_LINE(__LINE__, arg_tuple_size.hpp(function pointers))
# define N BOOST_PP_ITERATION()
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <class R BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
struct arg_tuple_size<R (*)(BOOST_PYTHON_UNARY_ENUM(N, A))>
{
BOOST_STATIC_CONSTANT(std::size_t, value = N);
};
# else
template<class R BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
char_array<N> arg_tuple_size_helper(
R (*)(BOOST_PYTHON_UNARY_ENUM(N, A)));
# endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
# undef N
// --------------- pointers-to-members --------------- //
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
// Outer iteration over cv-qualifications
# define BOOST_PP_ITERATION_PARAMS_2 \
3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/arg_tuple_size.hpp>)
# include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2 && BOOST_PP_RELATIVE_FLAGS(1) == BOOST_PYTHON_POINTER_TO_MEMBER
# line BOOST_PP_LINE(__LINE__, arg_tuple_size.hpp(pointers-to-members))
// Inner iteration over arities
# define N BOOST_PP_ITERATION()
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <class R, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
struct arg_tuple_size<R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q>
{
BOOST_STATIC_CONSTANT(std::size_t, value = N + 1U);
};
# else
template <class R, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
char_array<N + 1> arg_tuple_size_helper(
R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q);
# endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
# undef Q
# undef N
#endif // !defined(BOOST_PP_IS_ITERATING)

View File

@@ -1,23 +1,34 @@
// Copyright David Abrahams 2001. 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 CALLER_DWA20011214_HPP
# define CALLER_DWA20011214_HPP
#if !defined(BOOST_PP_IS_ITERATING)
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/returning.hpp>
# include <boost/mpl/select_type.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/type_traits/same_traits.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/aux_/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
// (C) Copyright David Abrahams 2000. 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.
//
// The author gratefully acknowleges the support of Dragon Systems, Inc., in
// producing this work.
//
// This file generated for 10-argument member functions and 11-argument free
// functions by gen_caller.python
# ifndef CALLER_DWA20011214_HPP
# define CALLER_DWA20011214_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/returning.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/type_traits/same_traits.hpp>
# // temp: include <boost/mpl/select_type.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
namespace boost { namespace python
{
template <class T> struct to_python;
template <class T> struct to_python;
}}
namespace boost { namespace python { namespace detail {
@@ -25,44 +36,71 @@ namespace boost { namespace python { namespace detail {
struct caller
{
typedef PyObject* result_type;
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/caller.hpp>
# endif
# define BOOST_PYTHON_CALLER_PF(args_, ignored) \
template < \
class P \
, class R \
BOOST_PP_COMMA_IF(args_) BOOST_MPL_TEMPLATE_PARAMETERS(0, args_, class A) \
> \
PyObject* operator()( \
BOOST_PYTHON_FN(*f,0,args_) \
, PyObject* args, PyObject* keywords \
, P const& policies \
) const \
{ \
return returning<R>::call(f, args, keywords,&policies); \
}
// function pointers
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/caller.hpp>, BOOST_PYTHON_FUNCTION_POINTER)
# include BOOST_PP_ITERATE()
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CALLER_PF, nil)
// pointers-to-members
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, 3, <boost/python/detail/caller.hpp>, BOOST_PYTHON_POINTER_TO_MEMBER)
# include BOOST_PP_ITERATE()
// Member functions
# define BOOST_PYTHON_CALLER_PMF(args_, cv) \
template <class P, class R, BOOST_MPL_TEMPLATE_PARAMETERS(0, args_, class A)> \
PyObject* operator()( \
BOOST_PYTHON_FN(A0::*f,1,args_)cv() \
, PyObject* args, PyObject* keywords \
, P const& policies \
) const \
{ \
return returning<R>::call(f, args, keywords,&policies); \
}
BOOST_PYTHON_REPEAT_MF_ALL_CV_2ND(BOOST_PYTHON_CALLER_PMF)
};
}}} // namespace boost::python::detail
#endif // CALLER_DWA20011214_HPP
# endif // CALLER_DWA20011214_HPP
/* ---------- function pointers --------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
# line BOOST_PP_LINE(__LINE__, detail/caller.hpp(function pointers))
# define N BOOST_PP_ITERATION()
template <
class P, class R
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
>
PyObject* operator()(
R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A))
, PyObject* args
, PyObject* keywords
, P const& policies) const
{
return returning<R>::call(pf, args, keywords, &policies);
}
# undef N
/* ---------- pointers-to-members ---------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
// outer over cv-qualifiers
# define BOOST_PP_ITERATION_PARAMS_2 3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/caller.hpp>)
# include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2
// inner over arities
#define N BOOST_PP_ITERATION()
#define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
template <
class P, class R, class T
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
>
PyObject* operator()(
R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q
, PyObject* args, PyObject* keywords
, P const& policies
) const
{
return returning<R>::call(pmf, args, keywords, &policies);
}
#undef N
#undef Q
#endif

View File

@@ -1,16 +1,21 @@
#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
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef MEMBER_FUNCTION_CAST_DWA2002311_HPP
# define MEMBER_FUNCTION_CAST_DWA2002311_HPP
# include <boost/mpl/select_type.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/aux_/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/dec.hpp>
# ifndef MEMBER_FUNCTION_CAST_DWA2002311_HPP
# define MEMBER_FUNCTION_CAST_DWA2002311_HPP
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/select_type.hpp>
# include <boost/type_traits/composite_traits.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
namespace boost { namespace python { namespace detail {
@@ -47,35 +52,19 @@ struct non_member_function_cast_impl
template <class T>
struct member_function_cast_impl
{
# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template <class U>
static non_member_function_cast_impl stage1(U)
{
return non_member_function_cast_impl();
}
# endif
# endif
// Member functions
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/member_function_cast.hpp>
# endif
# define BOOST_PYTHON_MEMBER_FUNCTION_CAST_STAGE1(args, cv) \
template < \
class S \
, class R \
BOOST_PP_COMMA_IF(BOOST_PP_DEC(args)) BOOST_MPL_TEMPLATE_PARAMETERS(1, args, class A) \
> \
static cast_helper<S,BOOST_PYTHON_FN(T::*,1,args)cv()> \
stage1(BOOST_PYTHON_FN(S::*,1,args)cv()) \
{ \
return cast_helper<S,BOOST_PYTHON_FN(T::*,1,args)cv()>(); \
}
BOOST_PYTHON_REPEAT_MF_ALL_CV_2ND(BOOST_PYTHON_MEMBER_FUNCTION_CAST_STAGE1)
# define BOOST_PP_ITERATION_PARAMS_1 3, (0, 3, <boost/python/detail/member_function_cast.hpp>)
# include BOOST_PP_ITERATE()
};
template <class T, class SF>
struct member_function_cast
# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
@@ -92,4 +81,32 @@ struct member_function_cast
}}} // namespace boost::python::detail
#endif // MEMBER_FUNCTION_CAST_DWA2002311_HPP
# endif // MEMBER_FUNCTION_CAST_DWA2002311_HPP
#elif BOOST_PP_ITERATION_DEPTH() == 1
// outer over cv-qualifiers
# define BOOST_PP_ITERATION_PARAMS_2 3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/member_function_cast.hpp>)
# include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2
# line BOOST_PP_LINE(__LINE__, member_function_cast.hpp)
// inner over arities
# define N BOOST_PP_ITERATION()
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
template <
class S, class R
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)
>
static cast_helper<S, R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q>
stage1(R (S::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q)
{
return cast_helper<S, R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q>();
}
# undef N
# undef Q
#endif

View File

@@ -6,105 +6,58 @@
#ifndef PREPROCESSOR_DWA200247_HPP
# define PREPROCESSOR_DWA200247_HPP
# include <boost/config.hpp>
# include <boost/preprocessor/tuple/to_list.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/tuple/elem.hpp>
# include <boost/preprocessor/list/for_each.hpp>
# include <boost/preprocessor/repeat_from_to_2nd.hpp>
# include <boost/preprocessor/inc.hpp>
# include <boost/preprocessor/empty.hpp>
# include <boost/preprocessor/enum.hpp>
# include <boost/preprocessor/expr_if.hpp>
namespace boost { namespace python { namespace detail {
// stuff that should be in the preprocessor library
# define BOOST_PYTHON_CONST() const
# define BOOST_PYTHON_VOLATILE() volatile
# define BOOST_PYTHON_CONST_VOLATILE() const volatile
# define BOOST_PYTHON_APPLY(x) BOOST_PP_CAT(BOOST_PYTHON_APPLY_, x)
# define BOOST_PYTHON_ALL_CV \
BOOST_PP_TUPLE_TO_LIST(4, (BOOST_PP_EMPTY \
, BOOST_PYTHON_CONST \
, BOOST_PYTHON_VOLATILE \
, BOOST_PYTHON_CONST_VOLATILE))
# define BOOST_PYTHON_APPLY_BOOST_PYTHON_ITEM(v) v
# define BOOST_PYTHON_APPLY_BOOST_PYTHON_NIL
// cv-qualifiers
# if !defined(__MWERKS__) || __MWERKS__ > 0x2407
# define BOOST_PYTHON_MEMBER_FUNCTION_CV BOOST_PYTHON_ALL_CV
# define BOOST_PYTHON_CV_COUNT 4
# else
# define BOOST_PYTHON_MEMBER_FUNCTION_CV BOOST_PP_TUPLE_TO_LIST(1, (BOOST_PP_EMPTY))
# endif
# define BOOST_PYTHON_CV_COUNT 1
# endif
#ifndef BOOST_PYTHON_DEBUGGABLE_ARITY
# define BOOST_PYTHON_DEBUGGABLE_ARITY 15
#endif
# ifndef BOOST_PYTHON_MAX_ARITY
# define BOOST_PYTHON_MAX_ARITY 15
# endif
#ifndef BOOST_PYTHON_MAX_ARITY
# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245
// Generate at least two more arguments just to test the syntax
# define BOOST_PYTHON_MAX_ARITY 17
# else
// Current EDG compilers have a really slow preprocessor which makes
// it important not to generate new functions with it unless
// absolutely neccessary
# define BOOST_PYTHON_MAX_ARITY BOOST_PYTHON_DEBUGGABLE_ARITY
# endif
#endif
# define BOOST_PYTHON_CV_QUALIFIER(i) \
BOOST_PYTHON_APPLY( \
BOOST_PP_TUPLE_ELEM(4, i, BOOST_PYTHON_CV_QUALIFIER_I) \
)
#ifdef BOOST_PYTHON_GENERATE_CODE
# undef BOOST_STATIC_CONSTANT
# define BOOST_PYTHON_ARITY_START 0
# define BOOST_PYTHON_ARITY_FINISH BOOST_PP_INC(BOOST_PYTHON_DEBUGGABLE_ARITY)
# define BOOST_PYTHON_MF_ARITY_START 1
# define BOOST_PYTHON_MF_ARITY_FINISH BOOST_PP_INC(BOOST_PP_INC(BOOST_PYTHON_DEBUGGABLE_ARITY))
#else
# define BOOST_PYTHON_ARITY_START BOOST_PP_INC(BOOST_PYTHON_DEBUGGABLE_ARITY)
# define BOOST_PYTHON_ARITY_FINISH BOOST_PP_INC(BOOST_PYTHON_MAX_ARITY)
# define BOOST_PYTHON_MF_ARITY_START BOOST_PP_INC(BOOST_PP_INC(BOOST_PYTHON_DEBUGGABLE_ARITY))
# define BOOST_PYTHON_MF_ARITY_FINISH BOOST_PP_INC(BOOST_PP_INC(BOOST_PYTHON_MAX_ARITY))
#endif
# define BOOST_PYTHON_CV_QUALIFIER_I \
( \
BOOST_PYTHON_NIL, \
BOOST_PYTHON_ITEM(const), \
BOOST_PYTHON_ITEM(volatile), \
BOOST_PYTHON_ITEM(const volatile) \
)
#if BOOST_PYTHON_MAX_ARITY > BOOST_PYTHON_DEBUGGABLE_ARITY
// enumerators
# define BOOST_PYTHON_UNARY_ENUM(c, text) BOOST_PP_REPEAT(c, BOOST_PYTHON_UNARY_ENUM_I, text)
# define BOOST_PYTHON_UNARY_ENUM_I(n, text) BOOST_PP_COMMA_IF(n) text ## n
# define BOOST_PYTHON_FN(inner,start,count) \
R(inner)(BOOST_MPL_TEMPLATE_PARAMETERS(start,count,A))
# define BOOST_PYTHON_BINARY_ENUM(c, a, b) BOOST_PP_REPEAT(c, BOOST_PYTHON_BINARY_ENUM_I, (a, b))
# define BOOST_PYTHON_BINARY_ENUM_I(n, _) BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, _), n) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 1, _), n)
# define BOOST_PYTHON_REPEAT_ARITY_2ND(function,data) \
BOOST_PP_REPEAT_FROM_TO_2ND( \
BOOST_PYTHON_ARITY_START, BOOST_PYTHON_ARITY_FINISH \
, function, data)
# define BOOST_PYTHON_ENUM_WITH_DEFAULT(c, text, def) BOOST_PP_REPEAT(c, BOOST_PYTHON_ENUM_WITH_DEFAULT_I, (text, def))
# define BOOST_PYTHON_ENUM_WITH_DEFAULT_I(n, _) BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, _), n) = BOOST_PP_TUPLE_ELEM(2, 1, _)
# define BOOST_PYTHON_REPEAT_MF_ARITY_2ND(function,data) \
BOOST_PP_REPEAT_FROM_TO_2ND( \
BOOST_PYTHON_MF_ARITY_START, BOOST_PYTHON_MF_ARITY_FINISH \
, function, data)
// fixed text (no commas)
# define BOOST_PYTHON_FIXED(n, text) text
# define BOOST_PYTHON_REPEAT_PMF_CV(index, function, cv) \
BOOST_PYTHON_REPEAT_MF_ARITY_2ND(function,cv)
# define BOOST_PYTHON_REPEAT_MF_CV_2ND(function) \
BOOST_PP_LIST_FOR_EACH(BOOST_PYTHON_REPEAT_PMF_CV,function,BOOST_PYTHON_MEMBER_FUNCTION_CV)
# define BOOST_PYTHON_REPEAT_MF_ALL_CV_2ND(function) \
BOOST_PP_LIST_FOR_EACH(BOOST_PYTHON_REPEAT_PMF_CV,function,BOOST_PYTHON_ALL_CV)
#define BOOST_PYTHON_NUMBER_PAIR(Index, Pair) \
BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2,0,Pair),Index) \
BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2,1,Pair),Index)
#define BOOST_PYTHON_ENUM_PARAMS2(N, Pair) BOOST_PP_ENUM(N, BOOST_PYTHON_NUMBER_PAIR, Pair)
# define BOOST_PYTHON_PROJECT_1ST(a1,a2) a1
# define BOOST_PYTHON_PROJECT_2ND(a1,a2) a2
#else
# define BOOST_PYTHON_REPEAT_ARITY_2ND(function,data)
# define BOOST_PYTHON_REPEAT_MF_ARITY_2ND(function,data)
# define BOOST_PYTHON_REPEAT_MF_ALL_CV_2ND(function)
# define BOOST_PYTHON_REPEAT_MF_CV_2ND(function)
# define BOOST_PYTHON_REPEAT_PMF_CV(index, function, cv)
#endif
}}} // namespace boost::python::detail
// flags
# define BOOST_PYTHON_FUNCTION_POINTER 0x0001
# define BOOST_PYTHON_POINTER_TO_MEMBER 0x0002
#endif // PREPROCESSOR_DWA200247_HPP

View File

@@ -1,20 +1,25 @@
#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
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef RESULT_DWA2002521_HPP
# define RESULT_DWA2002521_HPP
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/mpl/aux_/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/mpl/select_type.hpp>
# include <boost/type.hpp>
# include <boost/type_traits/object_traits.hpp>
# ifndef RESULT_DWA2002521_HPP
# define RESULT_DWA2002521_HPP
namespace boost { namespace python { namespace detail {
# include <boost/type.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/type_traits/object_traits.hpp>
# include <boost/mpl/select_type.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
namespace boost { namespace python { namespace detail {
// Defines a family of overloaded function which, given x, a function
// pointer, member [function] pointer, or an AdaptableFunction object,
@@ -25,20 +30,13 @@ namespace boost { namespace python { namespace detail {
// an AdaptableFunction object, you must pass OL as a second argument
// to get this to work portably.
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/result.hpp>
# endif
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/result.hpp>, BOOST_PYTHON_FUNCTION_POINTER)
# include BOOST_PP_ITERATE()
# define BOOST_PYTHON_FIRST_ARGUMENT_PF(args, ignored) \
template <class R BOOST_PP_COMMA_IF(args) BOOST_MPL_TEMPLATE_PARAMETERS(0, args, class A)> \
boost::type<R>* result(BOOST_PYTHON_FN(*,0,args), int = 0) { return 0; }
# define BOOST_PYTHON_FIRST_ARGUMENT_PMF(args, cv) \
template <class R, BOOST_MPL_TEMPLATE_PARAMETERS(0, args, class A)> \
boost::type<R>* result(BOOST_PYTHON_FN(A0::*,1,args)cv(), int = 0) { return 0; }
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_FIRST_ARGUMENT_PF, nil)
BOOST_PYTHON_REPEAT_MF_CV_2ND(BOOST_PYTHON_FIRST_ARGUMENT_PMF)
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, BOOST_PYTHON_CV_COUNT - 1, <boost/python/detail/result.hpp>, BOOST_PYTHON_POINTER_TO_MEMBER)
# include BOOST_PP_ITERATE()
template <class R, class T>
boost::type<R>* result(R (T::*), int = 0) { return 0; }
@@ -79,8 +77,47 @@ template <class X>
boost::type<typename X::result_type>*
result(X const&, short = 0) { return 0; }
# endif
# endif
}}} // namespace boost::python::detail
#endif // RESULT_DWA2002521_HPP
# endif // RESULT_DWA2002521_HPP
/* --------------- function pointers --------------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
# line BOOST_PP_LINE(__LINE__, result.hpp(function pointers))
# define N BOOST_PP_ITERATION()
template <class R BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
boost::type<R>* result(R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A)), int = 0)
{
return 0;
}
# undef N
/* --------------- pointers-to-members --------------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
// Outer over cv-qualifiers
# define BOOST_PP_ITERATION_PARAMS_2 3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/result.hpp>)
# include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2
# line BOOST_PP_LINE(__LINE__, result.hpp(pointers-to-members))
// Inner over arities
# define N BOOST_PP_ITERATION()
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
template <class R, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
boost::type<R>* result(R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q, int = 0)
{
return 0;
}
# undef N
# undef Q
#endif

View File

@@ -1,3 +1,5 @@
#if !defined(BOOST_PP_IS_ITERATING)
// (C) Copyright David Abrahams 2001,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
@@ -8,164 +10,205 @@
// This file generated for 5-argument member functions and 6-argument free
// functions by gen_returning.py
#ifndef RETURNING_DWA20011201_HPP
# define RETURNING_DWA20011201_HPP
# ifndef RETURNING_DWA20011201_HPP
# define RETURNING_DWA20011201_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/config.hpp>
# include <boost/python/detail/none.hpp>
# include <boost/python/arg_from_python.hpp>
# include <boost/mpl/apply.hpp>
# include <boost/config.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/preprocessor/enum.hpp>
# include <boost/preprocessor/enum_shifted.hpp>
# include <boost/preprocessor/expr_if.hpp>
# include <boost/preprocessor/repeat_from_to.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/python/arg_from_python.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/none.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/inc.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/mpl/apply.hpp>
namespace boost { namespace python { namespace detail {
# define BOOST_PYTHON_RETURNING_NON_VOID 0x0004
# define BOOST_PYTHON_RETURNING_VOID 0x0008
// Calling C++ from Python
template <class R>
struct returning
{
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/returning_non_void.hpp>
# endif
// Specializations for function pointers
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/returning.hpp>, \
BOOST_PYTHON_FUNCTION_POINTER | BOOST_PYTHON_RETURNING_NON_VOID)
# include BOOST_PP_ITERATE()
# define BOOST_PYTHON_ARG_CONVERTIBLE(index,ignored) \
arg_from_python<BOOST_PP_CAT(A,index)> \
BOOST_PP_CAT(c,index)(PyTuple_GET_ITEM(args_, index)); \
if (!BOOST_PP_CAT(c,index).convertible()) return 0;
# define BOOST_PYTHON_GET_ARG(index,ignored) \
BOOST_PP_CAT(c,index)(PyTuple_GET_ITEM(args_, index))
# define BOOST_PYTHON_RETURNING_NON_VOID_MF(args,cv) \
template <class P, BOOST_PP_ENUM_PARAMS(args,class A)> \
static PyObject* call( \
BOOST_PYTHON_FN(A0::*pmf,1,args) cv() \
, PyObject* args_, PyObject* \
, P const* policies) \
{ \
/* check that each of the arguments is convertible */ \
/* self argument is special */ \
arg_from_python<A0&> c0(PyTuple_GET_ITEM(args_, 0)); \
if (!c0.convertible()) return 0; \
\
/* Unroll a loop for the rest of them */ \
BOOST_PP_REPEAT_FROM_TO(1,args,BOOST_PYTHON_ARG_CONVERTIBLE,nil) \
\
/* find the result converter */ \
typedef typename P::result_converter result_converter; \
typename mpl::apply1<result_converter,R>::type cr; \
if (!cr.convertible()) return 0; \
\
if (!policies->precall(args_)) return 0; \
\
PyObject* result = cr( \
((BOOST_PYTHON_GET_ARG(0,nil)).*pmf)( \
BOOST_PP_ENUM_SHIFTED(args,BOOST_PYTHON_GET_ARG,nil)) \
); \
\
return policies->postcall(args_, result); \
}
// Generate a series for each cv-qualification
BOOST_PYTHON_REPEAT_MF_ALL_CV_2ND(BOOST_PYTHON_RETURNING_NON_VOID_MF)
# define BOOST_PYTHON_RETURNING_NON_VOID_FN(args,ignored) \
template <class P BOOST_PP_COMMA_IF(args) BOOST_PP_ENUM_PARAMS(args,class A)> \
static PyObject* call( \
BOOST_PYTHON_FN(*pf,0,args) \
, PyObject* args_ \
, PyObject* \
, P const* policies) \
{ \
/* check that each of the arguments is convertible */ \
BOOST_PP_REPEAT(args,BOOST_PYTHON_ARG_CONVERTIBLE,nil) \
\
/* find the result converter */ \
typedef typename P::result_converter result_converter; \
typename mpl::apply1<result_converter,R>::type cr; \
if (!cr.convertible()) return 0; \
\
if (!policies->precall(args_)) return 0; \
\
PyObject* result = cr( \
(*pf)(BOOST_PP_ENUM(args,BOOST_PYTHON_GET_ARG,nil)) \
); \
\
return policies->postcall(args_, result); \
}
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_RETURNING_NON_VOID_FN, nil)
// Specializations for member function pointers
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, 3, <boost/python/detail/returning.hpp>, \
BOOST_PYTHON_POINTER_TO_MEMBER | BOOST_PYTHON_RETURNING_NON_VOID)
# include BOOST_PP_ITERATE()
};
template <>
struct returning<void>
{
typedef void R;
// Specializations for function pointers
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/returning.hpp>, \
BOOST_PYTHON_FUNCTION_POINTER | BOOST_PYTHON_RETURNING_VOID)
# include BOOST_PP_ITERATE()
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/returning_void.hpp>
# endif
#define BOOST_PYTHON_RETURNING_VOID_MF(args,cv) \
template<class P,BOOST_PP_ENUM_PARAMS(args,class A)> \
static PyObject*call( \
BOOST_PYTHON_FN(A0::*pmf,1,args) cv() \
, PyObject*args_ \
, PyObject* \
, P const* policies) \
{ \
/* check that each of the arguments is convertible */ \
/* self argument is special */ \
arg_from_python<A0&>c0(PyTuple_GET_ITEM(args_,0)); \
if (!c0.convertible()) return 0; \
\
/* Unroll a loop for the rest of them */ \
BOOST_PP_REPEAT_FROM_TO(1,args,BOOST_PYTHON_ARG_CONVERTIBLE,nil) \
\
if (!policies->precall(args_)) return 0; \
\
((c0(PyTuple_GET_ITEM(args_,0))).*pmf)( \
BOOST_PP_ENUM_SHIFTED(args,BOOST_PYTHON_GET_ARG,nil) \
); \
\
return policies->postcall(args_,detail::none()); \
}
//Generate a series for each cv-qualification
BOOST_PYTHON_REPEAT_MF_ALL_CV_2ND(BOOST_PYTHON_RETURNING_VOID_MF)
#define BOOST_PYTHON_RETURNING_VOID_FN(args,ignored) \
template<class P BOOST_PP_COMMA_IF(args) BOOST_PP_ENUM_PARAMS(args,class A)> \
static PyObject*call( \
BOOST_PYTHON_FN(*pf,0,args) \
, PyObject*args_ \
, PyObject* \
, P const* policies) \
{ \
/*check that each of the arguments is convertible*/ \
BOOST_PP_REPEAT(args,BOOST_PYTHON_ARG_CONVERTIBLE,nil) \
\
BOOST_PP_EXPR_IF(args,if (!policies->precall(args_)) return 0;) \
\
(*pf)(BOOST_PP_ENUM(args,BOOST_PYTHON_GET_ARG,nil)); \
\
return policies->postcall(args_,detail::none()); \
}
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_RETURNING_VOID_FN,nil)
// Specializations for member function pointers
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, 3, <boost/python/detail/returning.hpp>, \
BOOST_PYTHON_POINTER_TO_MEMBER | BOOST_PYTHON_RETURNING_VOID)
# include BOOST_PP_ITERATE()
};
}}} // namespace boost::python::detail
#endif//RETURNING_DWA20011201_HPP
# undef BOOST_PYTHON_RETURNING_NON_VOID
# undef BOOST_PYTHON_RETURNING_VOID
# endif // RETURNING_DWA20011201_HPP
// --------------- function pointers --------------- //
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() & BOOST_PYTHON_FUNCTION_POINTER
# line BOOST_PP_LINE(__LINE__, returning.hpp(function pointers))
# define N BOOST_PP_ITERATION()
# define BOOST_PYTHON_CALL_ARGS(n, _) \
BOOST_PP_COMMA_IF(n) c##n(PyTuple_GET_ITEM(args_, n))
# define BOOST_PYTHON_CHECK_CONVERSION(n, _) \
arg_from_python<A##n> c##n(PyTuple_GET_ITEM(args_, n)); \
if (!c##n.convertible()) \
return 0;
# if (BOOST_PP_ITERATION_FLAGS() & BOOST_PYTHON_RETURNING_NON_VOID)
template<class P BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
static PyObject* call(
R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A))
, PyObject* args_
, PyObject*, P const* policies)
{
// check that each of the arguments is convertible
BOOST_PP_REPEAT(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
// find the result converter
typedef typename P::result_converter result_converter;
typename mpl::apply1<result_converter, R>::type cr;
if (!cr.convertible() || !policies->precall(args_))
return 0;
PyObject* result = cr(
(*pf)(BOOST_PP_REPEAT(N, BOOST_PYTHON_CALL_ARGS, nil))
);
return policies->postcall(args_, result);
}
# elif (BOOST_PP_ITERATION_FLAGS() & BOOST_PYTHON_RETURNING_VOID)
template<class P BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
static PyObject* call(
R (*pf)(BOOST_PYTHON_UNARY_ENUM(N, A))
, PyObject* args_
, PyObject*, P const* policies)
{
// check that each of the arguments is convertible
BOOST_PP_REPEAT(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
if (!policies->precall(args_))
return 0;
(*pf)(BOOST_PP_REPEAT(N, BOOST_PYTHON_CALL_ARGS, nil));
return policies->postcall(args_, detail::none());
}
# endif // returning void / non-void
# undef N
# undef BOOST_PYTHON_CALL_ARGS
# undef BOOST_PYTHON_CHECK_CONVERSION
// --------------- pointers to members --------------- //
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() & BOOST_PYTHON_POINTER_TO_MEMBER
// Outer iteration over cv-qualifications
# define BOOST_PP_ITERATION_PARAMS_2 \
3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/returning.hpp>)
# include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2 && BOOST_PP_RELATIVE_FLAGS(1) & BOOST_PYTHON_POINTER_TO_MEMBER
# line BOOST_PP_LINE(__LINE__, returning.hpp(pointers-to-members))
// Inner iteration over arities
# define N BOOST_PP_ITERATION()
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
# define BOOST_PYTHON_CALL_ARGS(n, _) \
BOOST_PP_COMMA_IF(n) c##n(PyTuple_GET_ITEM(args_, BOOST_PP_INC(n)))
# define BOOST_PYTHON_CHECK_CONVERSION(n, _) \
arg_from_python<A##n> c##n(PyTuple_GET_ITEM(args_, BOOST_PP_INC(n))); \
if (!c##n.convertible()) \
return 0;
# if (BOOST_PP_RELATIVE_FLAGS(1) & BOOST_PYTHON_RETURNING_NON_VOID)
template<class P, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
static PyObject* call(
R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q
, PyObject* args_
, PyObject*, P const* policies)
{
// check that each of the arguments is convertible
// self is special
arg_from_python<T&> ct(PyTuple_GET_ITEM(args_, 0));
if (!ct.convertible())
return 0;
// unroll a loop for the rest of them
BOOST_PP_REPEAT(N, BOOST_PYTHON_CHECK_CONVERSION, nil)
// find the result converter
typedef typename P::result_converter result_converter;
typename mpl::apply1<result_converter, R>::type cr;
if (!cr.convertible() || !policies->precall(args_))
return 0;
PyObject* result = cr(
((ct(PyTuple_GET_ITEM(args_, 0))).*pmf)(
BOOST_PP_REPEAT(N, BOOST_PYTHON_CALL_ARGS, nil))
);
return policies->postcall(args_, result);
}
# elif (BOOST_PP_RELATIVE_FLAGS(1) & BOOST_PYTHON_RETURNING_VOID)
template<class P, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
static PyObject* call(
R (T::*pmf)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q
, PyObject* args_
, PyObject*, P const* policies)
{
// check that each of the arguments is convertible
// self is special
arg_from_python<T&> ct(PyTuple_GET_ITEM(args_, 0));
if (!ct.convertible())
return 0;
// unroll a loop for the rest of them
BOOST_PP_REPEAT(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));
return policies->postcall(args_, detail::none());
}
# endif
# undef N
# undef Q
# undef BOOST_PYTHON_CALL_ARGS
# undef BOOST_PYTHON_CHECK_CONVERSION
#endif

View File

@@ -1,38 +1,74 @@
#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
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef TARGET_DWA2002521_HPP
# define TARGET_DWA2002521_HPP
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/mpl/aux_/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/if.hpp>
# include <boost/type.hpp>
# ifndef TARGET_DWA2002521_HPP
# define TARGET_DWA2002521_HPP
namespace boost { namespace python { namespace detail {
# include <boost/python/detail/preprocessor.hpp>
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/target.hpp>
# endif
# include <boost/type.hpp>
# define BOOST_PYTHON_FIRST_ARGUMENT_PF(args, ignored) \
template <class R BOOST_PP_COMMA_IF(args) BOOST_MPL_TEMPLATE_PARAMETERS(0, args, class A)> \
boost::type<BOOST_PP_IF(args, A0, void)>* target(BOOST_PYTHON_FN(*,0,args)) { return 0; }
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/if.hpp>
# include <boost/preprocessor/iterate.hpp>
# define BOOST_PYTHON_FIRST_ARGUMENT_PMF(args, cv) \
template <class R, BOOST_MPL_TEMPLATE_PARAMETERS(0, args, class A)> \
boost::type<A0 cv()*>* target(BOOST_PYTHON_FN(A0::*,1,args)cv()) { return 0; }
namespace boost { namespace python { namespace detail {
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_FIRST_ARGUMENT_PF, nil)
BOOST_PYTHON_REPEAT_MF_CV_2ND(BOOST_PYTHON_FIRST_ARGUMENT_PMF)
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/target.hpp>, BOOST_PYTHON_FUNCTION_POINTER)
# include BOOST_PP_ITERATE()
# define BOOST_PP_ITERATION_PARAMS_1 \
4, (0, BOOST_PYTHON_CV_COUNT - 1, <boost/python/detail/target.hpp>, BOOST_PYTHON_POINTER_TO_MEMBER)
# include BOOST_PP_ITERATE()
template <class R, class T>
boost::type<T*>* target(R (T::*)) { return 0; }
}}} // namespace boost::python::detail
#endif // TARGET_DWA2002521_HPP
# endif // TARGET_DWA2002521_HPP
/* --------------- function pointers --------------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_FUNCTION_POINTER
# line BOOST_PP_LINE(__LINE__, target.hpp(function_pointers))
# define N BOOST_PP_ITERATION()
template <class R BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
boost::type<BOOST_PP_IF(N, A0, void)>* target(R (*)(BOOST_PYTHON_UNARY_ENUM(N, A)))
{
return 0;
}
# undef N
/* --------------- pointers-to-members --------------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == BOOST_PYTHON_POINTER_TO_MEMBER
// Outer over cv-qualifiers
# define BOOST_PP_ITERATION_PARAMS_2 3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/target.hpp>)
# include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2
# line BOOST_PP_LINE(__LINE__, target.hpp(pointers-to-members))
// Inner over arities
# define N BOOST_PP_ITERATION()
# define Q BOOST_PYTHON_CV_QUALIFIER(BOOST_PP_RELATIVE_ITERATION(1))
template <class R, class T BOOST_PP_COMMA_IF(N) BOOST_PYTHON_UNARY_ENUM(N, class A)>
boost::type<T Q*>* target(R (T::*)(BOOST_PYTHON_UNARY_ENUM(N, A)) Q)
{
return 0;
}
# undef N
# undef Q
#endif

View File

@@ -1,23 +0,0 @@
// 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 AUTO_PTR_GENERATOR_DWA2002123_HPP
# define AUTO_PTR_GENERATOR_DWA2002123_HPP
# include <memory>
namespace boost { namespace python { namespace object {
struct auto_ptr_generator
{
template <class T>
struct apply
{
typedef std::auto_ptr<T> type;
};
};
}}} // namespace boost::python::object
#endif // AUTO_PTR_GENERATOR_DWA2002123_HPP

View File

@@ -1,58 +1,68 @@
#if !defined(BOOST_PP_IS_ITERATING)
// Copyright David Abrahams 2001. 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 MAKE_HOLDER_DWA20011215_HPP
# define MAKE_HOLDER_DWA20011215_HPP
# include <boost/mpl/at.hpp>
# include <boost/python/object/forward.hpp>
# include <boost/python/object/class.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/enum.hpp>
# ifndef MAKE_HOLDER_DWA20011215_HPP
# define MAKE_HOLDER_DWA20011215_HPP
namespace boost { namespace python { namespace objects {
# include <boost/python/object/forward.hpp>
# include <boost/python/object/class.hpp>
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/at.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/repeat.hpp>
namespace boost { namespace python { namespace objects {
template <int nargs> struct make_holder;
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/make_holder.hpp>
# endif
# define BOOST_PYTHON_FORWARD_ARG(index, _) \
typedef typename mpl::at<index,ArgList>::type t##index; \
typedef typename forward<t##index>::type f##index;
# define BOOST_PYTHON_DO_FORWARD_ARG(index, _) , f##index(a##index)
# define BOOST_PYTHON_FORWARD_ARG(index, ignored) \
typedef typename mpl::at<index,ArgList>::type BOOST_PP_CAT(t,index); \
typedef typename forward<BOOST_PP_CAT(t,index)>::type BOOST_PP_CAT(f,index);
// specializations...
# define BOOST_PP_ITERATION_PARAMS_1 3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/make_holder.hpp>)
# include BOOST_PP_ITERATE()
# define BOOST_PYTHON_DO_FORWARD_ARG(index, ignored) \
BOOST_PP_CAT(f,index)(BOOST_PP_CAT(a, index))
# define BOOST_PYTHON_MAKE_HOLDER(nargs,ignored) \
template <> \
struct make_holder<nargs> \
{ \
template <class Holder, class ArgList> \
struct apply \
{ \
BOOST_PP_REPEAT(nargs, BOOST_PYTHON_FORWARD_ARG, nil) \
\
static void execute( \
PyObject* p \
BOOST_PP_COMMA_IF(nargs) BOOST_PYTHON_ENUM_PARAMS2(nargs, (t,a)) ) \
{ \
(new Holder( \
p \
BOOST_PP_COMMA_IF(nargs) BOOST_PP_ENUM( \
nargs,BOOST_PYTHON_DO_FORWARD_ARG,nil)))->install(p); \
} \
}; \
};
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_MAKE_HOLDER,nil)
# undef BOOST_PYTHON_FORWARD_ARG
# undef BOOST_PYTHON_DO_FORWARD_ARG
}}} // namespace boost::python::objects
#endif // MAKE_HOLDER_DWA20011215_HPP
# endif // MAKE_HOLDER_DWA20011215_HPP
#elif BOOST_PP_ITERATION_DEPTH() == 1
# line BOOST_PP_LINE(__LINE__, make_holder.hpp)
# define N BOOST_PP_ITERATION()
template <>
struct make_holder<N>
{
template <class Holder, class ArgList>
struct apply
{
BOOST_PP_REPEAT(N, BOOST_PYTHON_FORWARD_ARG, nil)
static void execute(
PyObject* p
BOOST_PP_COMMA_IF(N) BOOST_PYTHON_BINARY_ENUM(N, t, a))
{
(new Holder(
p BOOST_PP_REPEAT(N, BOOST_PYTHON_DO_FORWARD_ARG, nil)))->install(p);
}
};
};
# undef N
#endif

View File

@@ -1,25 +1,35 @@
#if !defined(BOOST_PP_IS_ITERATING)
// Copyright David Abrahams 2001. 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 POINTER_HOLDER_DWA20011215_HPP
# define POINTER_HOLDER_DWA20011215_HPP
# include <boost/python/object/class.hpp>
# include <boost/python/type_id.hpp>
# include <boost/python/object/inheritance.hpp>
# include <boost/python/object/find_instance.hpp>
# include <boost/python/object/forward.hpp>
# include <boost/type.hpp>
# include <boost/mpl/select_type.hpp>
# include <boost/mpl/apply.hpp>
# include <boost/python/pointee.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/python/detail/force_instantiate.hpp>
# ifndef POINTER_HOLDER_DWA20011215_HPP
# define POINTER_HOLDER_DWA20011215_HPP
namespace boost { namespace python { namespace objects {
# include <boost/type.hpp>
# include <boost/python/object/class.hpp>
# include <boost/python/type_id.hpp>
# include <boost/python/object/inheritance.hpp>
# include <boost/python/object/find_instance.hpp>
# include <boost/python/object/forward.hpp>
# include <boost/python/pointee.hpp>
# include <boost/python/detail/force_instantiate.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/mpl/select_type.hpp>
# include <boost/mpl/apply.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/repeat.hpp>
namespace boost { namespace python { namespace objects {
# define BOOST_PYTHON_UNFORWARD_LOCAL(n, _) BOOST_PP_COMMA_IF(n) (typename unforward<A##n>::type)(a##n)
template <class Pointer, class Value>
struct pointer_holder : instance_holder
@@ -27,25 +37,10 @@ struct pointer_holder : instance_holder
pointer_holder(Pointer);
// Forward construction to the held object
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/pointer_holder.hpp>
# endif
# define BOOST_PP_ITERATION_PARAMS_1 4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/pointer_holder.hpp>, 1)
# include BOOST_PP_ITERATE()
# define BOOST_PYTHON_CONSTRUCT_POINTER_HOLDER(nargs, ignored) \
BOOST_PP_EXPR_IF(nargs, template <) \
BOOST_PP_ENUM_PARAMS(nargs, class A) \
BOOST_PP_EXPR_IF(nargs, >) \
pointer_holder(PyObject* \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,a))) \
: m_p(new Value( \
BOOST_PP_ENUM(nargs, BOOST_PYTHON_UNFORWARD, nil) \
)) \
{}
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_POINTER_HOLDER,nil)
private: // required holder implementation
void* holds(type_info);
@@ -59,30 +54,12 @@ struct pointer_holder_back_reference : instance_holder
private:
typedef typename python::pointee<Pointer>::type held_type;
public:
pointer_holder_back_reference(Pointer);
// Forward construction to the held object
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/ptr_holder_back_reference.hpp>
# endif
# define BOOST_PYTHON_CONSTRUCT_POINTER_HOLDER_BACK_REFERENCE(nargs, ignored) \
BOOST_PP_EXPR_IF(nargs, template <) \
BOOST_PP_ENUM_PARAMS(nargs, class A) \
BOOST_PP_EXPR_IF(nargs, >) \
pointer_holder_back_reference(PyObject* p \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,a))) \
: m_p(new held_type( \
p BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs, BOOST_PYTHON_UNFORWARD, nil) \
)) \
{ \
python::detail::force_instantiate(instance_finder<held_type>::registration); \
}
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_POINTER_HOLDER_BACK_REFERENCE,nil)
pointer_holder_back_reference(Pointer);
// Forward construction to the held object
# define BOOST_PP_ITERATION_PARAMS_1 4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/pointer_holder.hpp>, 2)
# include BOOST_PP_ITERATE()
private: // required holder implementation
void* holds(type_info);
@@ -91,6 +68,8 @@ struct pointer_holder_back_reference : instance_holder
Pointer m_p;
};
# undef BOOST_PYTHON_UNFORWARD_LOCAL
template <class Pointer, class Value>
inline pointer_holder<Pointer,Value>::pointer_holder(Pointer p)
: m_p(p)
@@ -130,4 +109,43 @@ void* pointer_holder_back_reference<Pointer, Value>::holds(type_info dst_t)
}}} // namespace boost::python::objects
#endif // POINTER_HOLDER_DWA20011215_HPP
# endif // POINTER_HOLDER_DWA20011215_HPP
/* --------------- pointer_holder --------------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 1
# line BOOST_PP_LINE(__LINE__, pointer_holder.hpp)
# define N BOOST_PP_ITERATION()
# if (N != 0)
template< BOOST_PYTHON_UNARY_ENUM(N, class A) >
# 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)
))
{}
# undef N
/* --------------- pointer_holder_back_reference --------------- */
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 2
# line BOOST_PP_LINE(__LINE__, pointer_holder.hpp(pointer_holder_back_reference))
# define N BOOST_PP_ITERATION()
# if (N != 0)
template < BOOST_PYTHON_UNARY_ENUM(N, class A) >
# endif
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)
))
{
python::detail::force_instantiate(instance_finder<held_type>::registration);
}
# undef N
#endif

View File

@@ -1,44 +1,37 @@
#if !defined(BOOST_PP_IS_ITERATING)
// Copyright David Abrahams 2001. 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 VALUE_HOLDER_DWA20011215_HPP
# define VALUE_HOLDER_DWA20011215_HPP
# include <boost/python/object/value_holder_fwd.hpp>
# include <boost/python/object/class.hpp>
# include <boost/python/type_id.hpp>
# include <boost/python/object/inheritance.hpp>
# include <boost/python/object/find_instance.hpp>
# include <boost/python/object/forward.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/enum_params.hpp>
# include <boost/python/detail/force_instantiate.hpp>
# ifndef VALUE_HOLDER_DWA20011215_HPP
# define VALUE_HOLDER_DWA20011215_HPP
# include <boost/python/object/value_holder_fwd.hpp>
# include <boost/python/object/class.hpp>
# include <boost/python/type_id.hpp>
# include <boost/python/object/inheritance.hpp>
# include <boost/python/object/find_instance.hpp>
# include <boost/python/object/forward.hpp>
# include <boost/python/detail/force_instantiate.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/comma_if.hpp>
# include <boost/preprocessor/iterate.hpp>
# include <boost/preprocessor/repeat.hpp>
namespace boost { namespace python { namespace objects {
# define BOOST_PYTHON_UNFORWARD_LOCAL(n, _) BOOST_PP_COMMA_IF(n) (typename unforward<A##n>::type)(a##n)
template <class Held>
struct value_holder : instance_holder
{
// Forward construction to the held object
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/value_holder.hpp>
# endif
# define BOOST_PYTHON_CONSTRUCT_VALUE_HOLDER(nargs, ignored) \
BOOST_PP_EXPR_IF(nargs, template <) \
BOOST_PP_ENUM_PARAMS(nargs, class A) \
BOOST_PP_EXPR_IF(nargs, >) \
value_holder(PyObject* \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,a))) \
: m_held( \
BOOST_PP_ENUM(nargs, BOOST_PYTHON_UNFORWARD, nil) \
) \
{}
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_VALUE_HOLDER,nil)
// Forward construction to the held object
# define BOOST_PP_ITERATION_PARAMS_1 4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/value_holder.hpp>, 1)
# include BOOST_PP_ITERATE()
private: // required holder implementation
void* holds(type_info);
@@ -51,34 +44,18 @@ template <class Held, class BackReferenceType>
struct value_holder_back_reference : instance_holder
{
// Forward construction to the held object
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/value_holder_back_reference.hpp>
# endif
# define BOOST_PYTHON_CONSTRUCT_VALUE_HOLDER_BACK_REFERENCE(nargs, ignored) \
BOOST_PP_EXPR_IF(nargs, template <) \
BOOST_PP_ENUM_PARAMS(nargs, class A) \
BOOST_PP_EXPR_IF(nargs, >) \
value_holder_back_reference(PyObject* p \
BOOST_PP_COMMA_IF(nargs) \
BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,a))) \
: m_held( \
p BOOST_PP_COMMA_IF(nargs) \
BOOST_PP_ENUM(nargs, BOOST_PYTHON_UNFORWARD, nil) \
) \
{ \
python::detail::force_instantiate(instance_finder<BackReferenceType>::registration); \
}
# define BOOST_PP_ITERATION_PARAMS_1 4, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/value_holder.hpp>, 2)
# include BOOST_PP_ITERATE()
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_VALUE_HOLDER_BACK_REFERENCE,nil)
private: // required holder implementation
private: // required holder implementation
void* holds(type_info);
private: // data members
BackReferenceType m_held;
};
# undef BOOST_PYTHON_UNFORWARD_LOCAL
template <class Held>
void* value_holder<Held>::holds(type_info dst_t)
{
@@ -104,4 +81,49 @@ void* value_holder_back_reference<Held,BackReferenceType>::holds(
}}} // namespace boost::python::objects
#endif // VALUE_HOLDER_DWA20011215_HPP
# endif // VALUE_HOLDER_DWA20011215_HPP
// --------------- value_holder ---------------
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 1
# line BOOST_PP_LINE(__LINE__, value_holder.hpp(value_holder))
# define N BOOST_PP_ITERATION()
# if (N != 0)
template <BOOST_PYTHON_UNARY_ENUM(N, class A)>
# endif
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)
)
{}
# undef N
// --------------- value_holder_back_reference ---------------
#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 2
# line BOOST_PP_LINE(__LINE__, value_holder.hpp(value_holder_back_reference))
# define N BOOST_PP_ITERATION()
# if (N != 0)
template <BOOST_PYTHON_UNARY_ENUM(N, class A)>
# endif
value_holder_back_reference(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)
)
{
python::detail::force_instantiate(instance_finder<BackReferenceType>::registration);
}
# undef N
#endif

View File

@@ -0,0 +1,22 @@
# // 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)
# error Boost.Python - do not include this file!
#endif
#define N BOOST_PP_ITERATION()
template <BOOST_PYTHON_UNARY_ENUM(N, class A)>
typename dependent<object, A0>::type
operator()(BOOST_PYTHON_BINARY_ENUM(N, A, const& a)) const
{
typedef typename dependent<object, A0>::type obj;
U const& self = *static_cast<U const*>(this);
return call<obj>(converter::get_managed_object(self), BOOST_PYTHON_UNARY_ENUM(N, a));
}
#undef N

View File

@@ -5,15 +5,18 @@
// to its suitability for any purpose.
#ifndef OBJECT_CORE_DWA2002615_HPP
# define OBJECT_CORE_DWA2002615_HPP
# include <boost/type.hpp>
# include <boost/python/handle.hpp>
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/python/call.hpp>
# include <boost/preprocessor/max.hpp>
# include <boost/python/slice_nil.hpp>
# include <boost/python/detail/raw_pyobject.hpp>
# include <boost/python/refcount.hpp>
# include <boost/type.hpp>
# include <boost/python/detail/preprocessor.hpp>
# include <boost/preprocessor/iterate.hpp>
namespace boost { namespace python {
@@ -99,23 +102,8 @@ namespace api
//
object operator()() const;
# ifndef BOOST_PYTHON_GENERATE_CODE
# include <boost/python/preprocessed/object_call.hpp>
# endif
# define BOOST_PYTHON_OBJECT_CALL(nargs,ignored) \
template <BOOST_PP_ENUM_PARAMS(nargs, class A)> \
typename dependent<object,A0>::type \
operator()(BOOST_PYTHON_ENUM_PARAMS2(nargs, (A,const& a))) const \
{ \
typedef typename dependent<object,A0>::type obj; \
U const& self = *static_cast<U const*>(this); \
return call<obj>(converter::get_managed_object(self), BOOST_PP_ENUM_PARAMS(nargs, a)); \
}
BOOST_PP_REPEAT_FROM_TO_2ND(
BOOST_PP_MAX(1, BOOST_PYTHON_ARITY_START), BOOST_PYTHON_ARITY_FINISH
, BOOST_PYTHON_OBJECT_CALL, ignored)
# define BOOST_PP_ITERATION_PARAMS_1 3, (1, BOOST_PYTHON_MAX_ARITY, <boost/python/object_call.hpp>)
# include BOOST_PP_ITERATE()
// truth value testing
//