mirror of
https://github.com/boostorg/python.git
synced 2026-01-26 06:42:27 +00:00
Use PP lib for holders
[SVN r13447]
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
# include <boost/mpl/select_type.hpp>
|
||||
# include <boost/mpl/apply.hpp>
|
||||
# include <boost/python/detail/pointee.hpp>
|
||||
# include <boost/python/detail/preprocessor.hpp>
|
||||
# include <boost/preprocessor/enum_params.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
@@ -22,125 +24,27 @@ template <class Pointer, class Value>
|
||||
struct pointer_holder : instance_holder
|
||||
{
|
||||
pointer_holder(Pointer);
|
||||
|
||||
|
||||
// Forward construction to the held object
|
||||
pointer_holder(PyObject*)
|
||||
: m_p(new Value) {}
|
||||
# ifndef BOOST_PYTHON_GENERATE_CODE
|
||||
# include <boost/python/preprocessed/pointer_holder.hpp>
|
||||
# endif
|
||||
|
||||
|
||||
template <class A1>
|
||||
pointer_holder(PyObject*, A1 a1)
|
||||
: m_p(new Value(
|
||||
(typename unforward<A1>::type)(a1)
|
||||
))
|
||||
{}
|
||||
|
||||
template <class A1, class A2>
|
||||
pointer_holder(PyObject*, A1 a1, A2 a2)
|
||||
: m_p(new Value(
|
||||
(typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
))
|
||||
{}
|
||||
|
||||
template <class A1, class A2, class A3>
|
||||
pointer_holder(PyObject*, A1 a1, A2 a2, A3 a3)
|
||||
: m_p(new Value(
|
||||
(typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
))
|
||||
{}
|
||||
|
||||
template <class A1, class A2, class A3, class A4>
|
||||
pointer_holder(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
: m_p(new Value(
|
||||
(typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
))
|
||||
{}
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5>
|
||||
pointer_holder(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
: m_p(new Value(
|
||||
(typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
)) {}
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
pointer_holder(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
: m_p(new Value(
|
||||
(typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
, (typename unforward<A6>::type)(a6)
|
||||
)) {}
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
pointer_holder(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
: m_p(new Value(
|
||||
(typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
, (typename unforward<A6>::type)(a6)
|
||||
, (typename unforward<A7>::type)(a7)
|
||||
))
|
||||
{}
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
pointer_holder(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
: m_p(new Value(
|
||||
(typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
, (typename unforward<A6>::type)(a6)
|
||||
, (typename unforward<A7>::type)(a7)
|
||||
, (typename unforward<A8>::type)(a8)
|
||||
))
|
||||
{}
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
pointer_holder(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
: m_p(new Value(
|
||||
(typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
, (typename unforward<A6>::type)(a6)
|
||||
, (typename unforward<A7>::type)(a7)
|
||||
, (typename unforward<A8>::type)(a8)
|
||||
, (typename unforward<A9>::type)(a9)
|
||||
))
|
||||
{}
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
|
||||
pointer_holder(PyObject*, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10)
|
||||
: m_p(new Value(
|
||||
(typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
, (typename unforward<A6>::type)(a6)
|
||||
, (typename unforward<A7>::type)(a7)
|
||||
, (typename unforward<A8>::type)(a8)
|
||||
, (typename unforward<A9>::type)(a9)
|
||||
, (typename unforward<A10>::type)(a10)
|
||||
))
|
||||
|
||||
# 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(converter::undecorated_type_id_t);
|
||||
|
||||
@@ -158,153 +62,26 @@ struct pointer_holder_back_reference : instance_holder
|
||||
pointer_holder_back_reference(Pointer);
|
||||
|
||||
// Forward construction to the held object
|
||||
pointer_holder_back_reference(PyObject* p)
|
||||
: m_p(new held_type(p)) {
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
}
|
||||
|
||||
template <class A1>
|
||||
pointer_holder_back_reference(PyObject* p, A1 a1)
|
||||
: m_p(new held_type(p
|
||||
, (typename unforward<A1>::type)(a1)
|
||||
))
|
||||
{
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
}
|
||||
|
||||
# ifndef BOOST_PYTHON_GENERATE_CODE
|
||||
# include <boost/python/preprocessed/pointer_holder_back_reference.hpp>
|
||||
# endif
|
||||
|
||||
template <class A1, class A2>
|
||||
pointer_holder_back_reference(PyObject* p, A1 a1, A2 a2)
|
||||
: m_p(new held_type(p
|
||||
, (typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
))
|
||||
{
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
}
|
||||
|
||||
|
||||
template <class A1, class A2, class A3>
|
||||
pointer_holder_back_reference(PyObject* p, A1 a1, A2 a2, A3 a3)
|
||||
: m_p(new held_type(p
|
||||
, (typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
))
|
||||
{
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
}
|
||||
|
||||
|
||||
template <class A1, class A2, class A3, class A4>
|
||||
pointer_holder_back_reference(PyObject* p, A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
: m_p(new held_type(p
|
||||
, (typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
))
|
||||
{
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
}
|
||||
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5>
|
||||
pointer_holder_back_reference(PyObject* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
: m_p(new held_type(p
|
||||
, (typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
)) {
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
}
|
||||
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5, class A6>
|
||||
pointer_holder_back_reference(PyObject* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
: m_p(new held_type(p
|
||||
, (typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
, (typename unforward<A6>::type)(a6)
|
||||
)) {
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
}
|
||||
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7>
|
||||
pointer_holder_back_reference(PyObject* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
: m_p(new held_type(p
|
||||
, (typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
, (typename unforward<A6>::type)(a6)
|
||||
, (typename unforward<A7>::type)(a7)
|
||||
))
|
||||
{
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
}
|
||||
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
|
||||
pointer_holder_back_reference(PyObject* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
: m_p(new held_type(p
|
||||
, (typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
, (typename unforward<A6>::type)(a6)
|
||||
, (typename unforward<A7>::type)(a7)
|
||||
, (typename unforward<A8>::type)(a8)
|
||||
))
|
||||
{
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
}
|
||||
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
|
||||
pointer_holder_back_reference(PyObject* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
: m_p(new held_type(p
|
||||
, (typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
, (typename unforward<A6>::type)(a6)
|
||||
, (typename unforward<A7>::type)(a7)
|
||||
, (typename unforward<A8>::type)(a8)
|
||||
, (typename unforward<A9>::type)(a9)
|
||||
))
|
||||
{
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
}
|
||||
|
||||
|
||||
template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
|
||||
pointer_holder_back_reference(PyObject* p, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10)
|
||||
: m_p(new held_type(p
|
||||
, (typename unforward<A1>::type)(a1)
|
||||
, (typename unforward<A2>::type)(a2)
|
||||
, (typename unforward<A3>::type)(a3)
|
||||
, (typename unforward<A4>::type)(a4)
|
||||
, (typename unforward<A5>::type)(a5)
|
||||
, (typename unforward<A6>::type)(a6)
|
||||
, (typename unforward<A7>::type)(a7)
|
||||
, (typename unforward<A8>::type)(a8)
|
||||
, (typename unforward<A9>::type)(a9)
|
||||
, (typename unforward<A10>::type)(a10)
|
||||
))
|
||||
{
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x;
|
||||
# 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_ENUM(nargs, BOOST_PYTHON_UNFORWARD, nil) \
|
||||
)) \
|
||||
{ \
|
||||
void const* x = &instance_finder<held_type>::registration; (void)x; \
|
||||
}
|
||||
|
||||
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_POINTER_HOLDER_BACK_REFERENCE,nil)
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(converter::undecorated_type_id_t);
|
||||
|
||||
Reference in New Issue
Block a user