mirror of
https://github.com/boostorg/python.git
synced 2026-01-27 07:02:15 +00:00
copy_mutable_reference -> copy_non_const_reference
arbitrary arg support for constructors [SVN r13508]
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#ifndef CLASS_FWD_DWA200222_HPP
|
||||
# define CLASS_FWD_DWA200222_HPP
|
||||
# include <boost/python/detail/not_specified.hpp>
|
||||
# include <boost/python/args.hpp>
|
||||
# include <boost/python/bases.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# include <boost/type_traits/transform_traits.hpp>
|
||||
# include <boost/type_traits/cv_traits.hpp>
|
||||
# include <boost/python/return_value_policy.hpp>
|
||||
# include <boost/python/copy_mutable_reference.hpp>
|
||||
# include <boost/python/copy_non_const_reference.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace detail
|
||||
template <class C, class D>
|
||||
objects::function* make_getter(D C::*pm)
|
||||
{
|
||||
typedef return_value_policy<copy_mutable_reference> default_policy;
|
||||
typedef return_value_policy<copy_non_const_reference> default_policy;
|
||||
return new objects::function(
|
||||
objects::py_function(
|
||||
::boost::bind(
|
||||
|
||||
@@ -10,158 +10,48 @@
|
||||
# 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>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
template <int nargs> struct make_holder;
|
||||
|
||||
template <>
|
||||
struct make_holder<0>
|
||||
{
|
||||
template <class Holder, class ArgList>
|
||||
struct apply
|
||||
{
|
||||
static void execute(
|
||||
PyObject* p)
|
||||
{
|
||||
(new Holder(p))->install(p);
|
||||
}
|
||||
};
|
||||
};
|
||||
# ifndef BOOST_PYTHON_GENERATE_CODE
|
||||
# include <boost/python/preprocessed/make_holder.hpp>
|
||||
# endif
|
||||
|
||||
|
||||
template <>
|
||||
struct make_holder<1>
|
||||
{
|
||||
template <class Holder, class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
|
||||
static void execute(
|
||||
PyObject* p
|
||||
, t0 a0)
|
||||
{
|
||||
(new Holder(p, f0(a0)))->install(p);
|
||||
}
|
||||
};
|
||||
# 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);
|
||||
|
||||
# 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); \
|
||||
} \
|
||||
}; \
|
||||
};
|
||||
|
||||
template <>
|
||||
struct make_holder<2>
|
||||
{
|
||||
template <class Holder, class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
|
||||
static void execute(
|
||||
PyObject* p, t0 a0, t1 a1)
|
||||
{
|
||||
(new Holder(p, f0(a0), f1(a1)))->install(p);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct make_holder<3>
|
||||
{
|
||||
template <class Holder, class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
|
||||
static void execute(
|
||||
PyObject* p, t0 a0, t1 a1, t2 a2)
|
||||
{
|
||||
(new Holder(p, f0(a0), f1(a1), f2(a2)))->install(p);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct make_holder<4>
|
||||
{
|
||||
template <class Holder, class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
typedef typename mpl::at<3,ArgList>::type t3;
|
||||
typedef typename forward<t3>::type f3;
|
||||
|
||||
static void execute(
|
||||
PyObject* p, t0 a0, t1 a1, t2 a2, t3 a3)
|
||||
{
|
||||
(new Holder(p, f0(a0), f1(a1), f2(a2), f3(a3)))->install(p);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct make_holder<5>
|
||||
{
|
||||
template <class Holder, class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
typedef typename mpl::at<3,ArgList>::type t3;
|
||||
typedef typename forward<t3>::type f3;
|
||||
typedef typename mpl::at<4,ArgList>::type t4;
|
||||
typedef typename forward<t4>::type f4;
|
||||
|
||||
static void execute(
|
||||
PyObject* p, t0 a0, t1 a1, t2 a2, t3 a3, t4 a4)
|
||||
{
|
||||
(new Holder(p, f0(a0), f1(a1), f2(a2), f3(a3), f4(a4)))->install(p);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct make_holder<6>
|
||||
{
|
||||
template <class Holder, class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
typedef typename mpl::at<3,ArgList>::type t3;
|
||||
typedef typename forward<t3>::type f3;
|
||||
typedef typename mpl::at<4,ArgList>::type t4;
|
||||
typedef typename forward<t4>::type f4;
|
||||
typedef typename mpl::at<5,ArgList>::type t5;
|
||||
typedef typename forward<t5>::type f5;
|
||||
|
||||
static void execute(
|
||||
PyObject* p, t0 a0, t1 a1, t2 a2, t3 a3, t4 a4, t5 a5)
|
||||
{
|
||||
(new Holder(p, f0(a0), f1(a1), f2(a2), f3(a3), f4(a4), f5(a5)))->install(p);
|
||||
}
|
||||
};
|
||||
};
|
||||
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_MAKE_HOLDER,nil)
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
|
||||
230
include/boost/python/preprocessed/make_holder.hpp
Normal file
230
include/boost/python/preprocessed/make_holder.hpp
Normal file
@@ -0,0 +1,230 @@
|
||||
// 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 MAKE_HOLDER_DWA2002416_HPP
|
||||
# define MAKE_HOLDER_DWA2002416_HPP
|
||||
|
||||
template<>
|
||||
struct make_holder<0>
|
||||
{
|
||||
template<class Holder,class ArgList>
|
||||
struct apply
|
||||
{
|
||||
static void execute(PyObject*p)
|
||||
{
|
||||
(new Holder(p))->install(p);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
template<>
|
||||
struct make_holder<1>
|
||||
{
|
||||
template<class Holder,class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
static void execute(PyObject*p,t0 a0)
|
||||
{
|
||||
(new Holder(p,f0(a0)))->install(p);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
template<>
|
||||
struct make_holder<2>
|
||||
{
|
||||
template<class Holder,class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
static void execute(PyObject*p,t0 a0,t1 a1)
|
||||
{
|
||||
(new Holder(p,f0(a0),f1(a1)))->install(p);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
template<>
|
||||
struct make_holder<3>
|
||||
{
|
||||
template<class Holder,class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
static void execute(PyObject*p,t0 a0,t1 a1,t2 a2)
|
||||
{
|
||||
(new Holder(p,f0(a0),f1(a1),f2(a2)))->install(p);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
template<>
|
||||
struct make_holder<4>
|
||||
{
|
||||
template<class Holder,class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
typedef typename mpl::at<3,ArgList>::type t3;
|
||||
typedef typename forward<t3>::type f3;
|
||||
static void execute(PyObject*p,t0 a0,t1 a1,t2 a2,t3 a3)
|
||||
{
|
||||
(new Holder(p,f0(a0),f1(a1),f2(a2),f3(a3)))->install(p);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
template<>
|
||||
struct make_holder<5>
|
||||
{
|
||||
template<class Holder,class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
typedef typename mpl::at<3,ArgList>::type t3;
|
||||
typedef typename forward<t3>::type f3;
|
||||
typedef typename mpl::at<4,ArgList>::type t4;
|
||||
typedef typename forward<t4>::type f4;
|
||||
static void execute(PyObject*p,t0 a0,t1 a1,t2 a2,t3 a3,t4 a4)
|
||||
{
|
||||
(new Holder(p,f0(a0),f1(a1),f2(a2),f3(a3),f4(a4)))->install(p);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
template<>
|
||||
struct make_holder<6>
|
||||
{
|
||||
template<class Holder,class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
typedef typename mpl::at<3,ArgList>::type t3;
|
||||
typedef typename forward<t3>::type f3;
|
||||
typedef typename mpl::at<4,ArgList>::type t4;
|
||||
typedef typename forward<t4>::type f4;
|
||||
typedef typename mpl::at<5,ArgList>::type t5;
|
||||
typedef typename forward<t5>::type f5;
|
||||
static void execute(PyObject*p,t0 a0,t1 a1,t2 a2,t3 a3,t4 a4,t5 a5)
|
||||
{
|
||||
(new Holder(p,f0(a0),f1(a1),f2(a2),f3(a3),f4(a4),f5(a5)))->install(p);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
template<>
|
||||
struct make_holder<7>
|
||||
{
|
||||
template<class Holder,class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
typedef typename mpl::at<3,ArgList>::type t3;
|
||||
typedef typename forward<t3>::type f3;
|
||||
typedef typename mpl::at<4,ArgList>::type t4;
|
||||
typedef typename forward<t4>::type f4;
|
||||
typedef typename mpl::at<5,ArgList>::type t5;
|
||||
typedef typename forward<t5>::type f5;
|
||||
typedef typename mpl::at<6,ArgList>::type t6;
|
||||
typedef typename forward<t6>::type f6;
|
||||
static void execute(PyObject*p,t0 a0,t1 a1,t2 a2,t3 a3,t4 a4,t5 a5,t6 a6)
|
||||
{
|
||||
(new Holder(p,f0(a0),f1(a1),f2(a2),f3(a3),f4(a4),f5(a5),f6(a6)))->install(p);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
template<>
|
||||
struct make_holder<8>
|
||||
{
|
||||
template<class Holder,class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
typedef typename mpl::at<3,ArgList>::type t3;
|
||||
typedef typename forward<t3>::type f3;
|
||||
typedef typename mpl::at<4,ArgList>::type t4;
|
||||
typedef typename forward<t4>::type f4;
|
||||
typedef typename mpl::at<5,ArgList>::type t5;
|
||||
typedef typename forward<t5>::type f5;
|
||||
typedef typename mpl::at<6,ArgList>::type t6;
|
||||
typedef typename forward<t6>::type f6;
|
||||
typedef typename mpl::at<7,ArgList>::type t7;
|
||||
typedef typename forward<t7>::type f7;
|
||||
static void execute(PyObject*p,t0 a0,t1 a1,t2 a2,t3 a3,t4 a4,t5 a5,t6 a6,t7 a7)
|
||||
{
|
||||
(new Holder(p,f0(a0),f1(a1),f2(a2),f3(a3),f4(a4),f5(a5),f6(a6),f7(a7)))->install(p);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
template<>
|
||||
struct make_holder<9>
|
||||
{
|
||||
template<class Holder,class ArgList>
|
||||
struct apply
|
||||
{
|
||||
typedef typename mpl::at<0,ArgList>::type t0;
|
||||
typedef typename forward<t0>::type f0;
|
||||
typedef typename mpl::at<1,ArgList>::type t1;
|
||||
typedef typename forward<t1>::type f1;
|
||||
typedef typename mpl::at<2,ArgList>::type t2;
|
||||
typedef typename forward<t2>::type f2;
|
||||
typedef typename mpl::at<3,ArgList>::type t3;
|
||||
typedef typename forward<t3>::type f3;
|
||||
typedef typename mpl::at<4,ArgList>::type t4;
|
||||
typedef typename forward<t4>::type f4;
|
||||
typedef typename mpl::at<5,ArgList>::type t5;
|
||||
typedef typename forward<t5>::type f5;
|
||||
typedef typename mpl::at<6,ArgList>::type t6;
|
||||
typedef typename forward<t6>::type f6;
|
||||
typedef typename mpl::at<7,ArgList>::type t7;
|
||||
typedef typename forward<t7>::type f7;
|
||||
typedef typename mpl::at<8,ArgList>::type t8;
|
||||
typedef typename forward<t8>::type f8;
|
||||
static void execute(PyObject*p,t0 a0,t1 a1,t2 a2,t3 a3,t4 a4,t5 a5,t6 a6,t7 a7,t8 a8)
|
||||
{
|
||||
(new Holder(p,f0(a0),f1(a1),f2(a2),f3(a3),f4(a4),f5(a5),f6(a6),f7(a7),f8(a8)))->install(p);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif // MAKE_HOLDER_DWA2002416_HPP
|
||||
Reference in New Issue
Block a user