diff --git a/include/boost/python/class_fwd.hpp b/include/boost/python/class_fwd.hpp index 1ef941aa..d88ec271 100644 --- a/include/boost/python/class_fwd.hpp +++ b/include/boost/python/class_fwd.hpp @@ -6,6 +6,8 @@ #ifndef CLASS_FWD_DWA200222_HPP # define CLASS_FWD_DWA200222_HPP # include +# include +# include namespace boost { namespace python { diff --git a/include/boost/python/data_members.hpp b/include/boost/python/data_members.hpp index fec774ae..b0f3f7b6 100644 --- a/include/boost/python/data_members.hpp +++ b/include/boost/python/data_members.hpp @@ -12,7 +12,7 @@ # include # include # include -# include +# include namespace boost { namespace python { @@ -63,7 +63,7 @@ namespace detail template objects::function* make_getter(D C::*pm) { - typedef return_value_policy default_policy; + typedef return_value_policy default_policy; return new objects::function( objects::py_function( ::boost::bind( diff --git a/include/boost/python/object/make_holder.hpp b/include/boost/python/object/make_holder.hpp index 59043317..1d55512c 100644 --- a/include/boost/python/object/make_holder.hpp +++ b/include/boost/python/object/make_holder.hpp @@ -10,158 +10,48 @@ # include # include # include +# include +# include +# include namespace boost { namespace python { namespace objects { template struct make_holder; -template <> -struct make_holder<0> -{ - template - struct apply - { - static void execute( - PyObject* p) - { - (new Holder(p))->install(p); - } - }; -}; +# ifndef BOOST_PYTHON_GENERATE_CODE +# include +# endif -template <> -struct make_holder<1> -{ - template - struct apply - { - typedef typename mpl::at<0,ArgList>::type t0; - typedef typename forward::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::type BOOST_PP_CAT(t,index); \ + typedef typename forward::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 \ +{ \ + template \ + 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 - struct apply - { - typedef typename mpl::at<0,ArgList>::type t0; - typedef typename forward::type f0; - typedef typename mpl::at<1,ArgList>::type t1; - typedef typename forward::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 - struct apply - { - typedef typename mpl::at<0,ArgList>::type t0; - typedef typename forward::type f0; - typedef typename mpl::at<1,ArgList>::type t1; - typedef typename forward::type f1; - typedef typename mpl::at<2,ArgList>::type t2; - typedef typename forward::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 - struct apply - { - typedef typename mpl::at<0,ArgList>::type t0; - typedef typename forward::type f0; - typedef typename mpl::at<1,ArgList>::type t1; - typedef typename forward::type f1; - typedef typename mpl::at<2,ArgList>::type t2; - typedef typename forward::type f2; - typedef typename mpl::at<3,ArgList>::type t3; - typedef typename forward::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 - struct apply - { - typedef typename mpl::at<0,ArgList>::type t0; - typedef typename forward::type f0; - typedef typename mpl::at<1,ArgList>::type t1; - typedef typename forward::type f1; - typedef typename mpl::at<2,ArgList>::type t2; - typedef typename forward::type f2; - typedef typename mpl::at<3,ArgList>::type t3; - typedef typename forward::type f3; - typedef typename mpl::at<4,ArgList>::type t4; - typedef typename forward::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 - struct apply - { - typedef typename mpl::at<0,ArgList>::type t0; - typedef typename forward::type f0; - typedef typename mpl::at<1,ArgList>::type t1; - typedef typename forward::type f1; - typedef typename mpl::at<2,ArgList>::type t2; - typedef typename forward::type f2; - typedef typename mpl::at<3,ArgList>::type t3; - typedef typename forward::type f3; - typedef typename mpl::at<4,ArgList>::type t4; - typedef typename forward::type f4; - typedef typename mpl::at<5,ArgList>::type t5; - typedef typename forward::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 diff --git a/include/boost/python/preprocessed/make_holder.hpp b/include/boost/python/preprocessed/make_holder.hpp new file mode 100644 index 00000000..88eecbc1 --- /dev/null +++ b/include/boost/python/preprocessed/make_holder.hpp @@ -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 + struct apply + { + static void execute(PyObject*p) + { + (new Holder(p))->install(p); + } + + }; +}; +template<> +struct make_holder<1> +{ + template + struct apply + { + typedef typename mpl::at<0,ArgList>::type t0; + typedef typename forward::type f0; + static void execute(PyObject*p,t0 a0) + { + (new Holder(p,f0(a0)))->install(p); + } + + }; +}; +template<> +struct make_holder<2> +{ + template + struct apply + { + typedef typename mpl::at<0,ArgList>::type t0; + typedef typename forward::type f0; + typedef typename mpl::at<1,ArgList>::type t1; + typedef typename forward::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 + struct apply + { + typedef typename mpl::at<0,ArgList>::type t0; + typedef typename forward::type f0; + typedef typename mpl::at<1,ArgList>::type t1; + typedef typename forward::type f1; + typedef typename mpl::at<2,ArgList>::type t2; + typedef typename forward::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 + struct apply + { + typedef typename mpl::at<0,ArgList>::type t0; + typedef typename forward::type f0; + typedef typename mpl::at<1,ArgList>::type t1; + typedef typename forward::type f1; + typedef typename mpl::at<2,ArgList>::type t2; + typedef typename forward::type f2; + typedef typename mpl::at<3,ArgList>::type t3; + typedef typename forward::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 + struct apply + { + typedef typename mpl::at<0,ArgList>::type t0; + typedef typename forward::type f0; + typedef typename mpl::at<1,ArgList>::type t1; + typedef typename forward::type f1; + typedef typename mpl::at<2,ArgList>::type t2; + typedef typename forward::type f2; + typedef typename mpl::at<3,ArgList>::type t3; + typedef typename forward::type f3; + typedef typename mpl::at<4,ArgList>::type t4; + typedef typename forward::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 + struct apply + { + typedef typename mpl::at<0,ArgList>::type t0; + typedef typename forward::type f0; + typedef typename mpl::at<1,ArgList>::type t1; + typedef typename forward::type f1; + typedef typename mpl::at<2,ArgList>::type t2; + typedef typename forward::type f2; + typedef typename mpl::at<3,ArgList>::type t3; + typedef typename forward::type f3; + typedef typename mpl::at<4,ArgList>::type t4; + typedef typename forward::type f4; + typedef typename mpl::at<5,ArgList>::type t5; + typedef typename forward::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 + struct apply + { + typedef typename mpl::at<0,ArgList>::type t0; + typedef typename forward::type f0; + typedef typename mpl::at<1,ArgList>::type t1; + typedef typename forward::type f1; + typedef typename mpl::at<2,ArgList>::type t2; + typedef typename forward::type f2; + typedef typename mpl::at<3,ArgList>::type t3; + typedef typename forward::type f3; + typedef typename mpl::at<4,ArgList>::type t4; + typedef typename forward::type f4; + typedef typename mpl::at<5,ArgList>::type t5; + typedef typename forward::type f5; + typedef typename mpl::at<6,ArgList>::type t6; + typedef typename forward::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 + struct apply + { + typedef typename mpl::at<0,ArgList>::type t0; + typedef typename forward::type f0; + typedef typename mpl::at<1,ArgList>::type t1; + typedef typename forward::type f1; + typedef typename mpl::at<2,ArgList>::type t2; + typedef typename forward::type f2; + typedef typename mpl::at<3,ArgList>::type t3; + typedef typename forward::type f3; + typedef typename mpl::at<4,ArgList>::type t4; + typedef typename forward::type f4; + typedef typename mpl::at<5,ArgList>::type t5; + typedef typename forward::type f5; + typedef typename mpl::at<6,ArgList>::type t6; + typedef typename forward::type f6; + typedef typename mpl::at<7,ArgList>::type t7; + typedef typename forward::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 + struct apply + { + typedef typename mpl::at<0,ArgList>::type t0; + typedef typename forward::type f0; + typedef typename mpl::at<1,ArgList>::type t1; + typedef typename forward::type f1; + typedef typename mpl::at<2,ArgList>::type t2; + typedef typename forward::type f2; + typedef typename mpl::at<3,ArgList>::type t3; + typedef typename forward::type f3; + typedef typename mpl::at<4,ArgList>::type t4; + typedef typename forward::type f4; + typedef typename mpl::at<5,ArgList>::type t5; + typedef typename forward::type f5; + typedef typename mpl::at<6,ArgList>::type t6; + typedef typename forward::type f6; + typedef typename mpl::at<7,ArgList>::type t7; + typedef typename forward::type f7; + typedef typename mpl::at<8,ArgList>::type t8; + typedef typename forward::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