From 7ecd7e84d99133fb3c5be3cfd4434b40fb65ee2d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 21 May 2002 16:37:30 +0000 Subject: [PATCH] Cleaned up internals and generalized detail::target() [SVN r13998] --- include/boost/python/detail/target.hpp | 95 +---- include/boost/python/iterator.hpp | 18 +- include/boost/python/object/iterator.hpp | 4 +- include/boost/python/preprocessed/target.hpp | 402 +++++++++++++++++++ 4 files changed, 435 insertions(+), 84 deletions(-) create mode 100755 include/boost/python/preprocessed/target.hpp diff --git a/include/boost/python/detail/target.hpp b/include/boost/python/detail/target.hpp index e0c693dd..e6869140 100644 --- a/include/boost/python/detail/target.hpp +++ b/include/boost/python/detail/target.hpp @@ -3,87 +3,36 @@ // 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_DWA2002513_HPP -# define TARGET_DWA2002513_HPP +#ifndef TARGET_DWA2002521_HPP +# define TARGET_DWA2002521_HPP +# include +# include +# include +# include +# include # include -namespace boost { namespace python { namespace detail { +namespace boost { namespace python { namespace detail { -// -// target(x) - deduce the type of the first argument when bind(x) is -// invoked. -// +# ifndef BOOST_PYTHON_GENERATE_CODE +# include +# endif -// functions -template -boost::type* target(R (*)(Target)) { return 0; } +# define BOOST_PYTHON_FIRST_ARGUMENT_PF(args, ignored) \ +template \ +boost::type* target(BOOST_PYTHON_FN(*,0,args)) { return 0; } -template -boost::type* target(R (*)(Target, A1)) { return 0; } - -template -boost::type* target(R (*)(Target, A1, A2)) { return 0; } - -template -boost::type* target(R (*)(Target, A1, A2, A3)) { return 0; } +# define BOOST_PYTHON_FIRST_ARGUMENT_PMF(args, cv) \ +template \ +boost::type* target(BOOST_PYTHON_FN(A0::*,1,args)cv()) { return 0; } -// data member pointers -template -boost::type* target(R (Target::*)) { return 0; } +BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_FIRST_ARGUMENT_PF, nil) +BOOST_PYTHON_REPEAT_MF_CV_2ND(BOOST_PYTHON_FIRST_ARGUMENT_PMF) -// member Functions -template -boost::type* target(R (Target::*)()) { return 0; } - -template -boost::type* target(R (Target::*)(A1)) { return 0; } - -template -boost::type* target(R (Target::*)(A1,A2)) { return 0; } - -template -boost::type* target(R (Target::*)(A1,A2,A3)) { return 0; } - -// const member functions -template -boost::type* target(R (Target::*)() const) { return 0; } - -template -boost::type* target(R (Target::*)(A1) const) { return 0; } - -template -boost::type* target(R (Target::*)(A1,A2) const) { return 0; } - -template -boost::type* target(R (Target::*)(A1,A2,A3) const) { return 0; } - -// volatile member functions -template -boost::type* target(R (Target::*)() volatile) { return 0; } - -template -boost::type* target(R (Target::*)(A1) volatile) { return 0; } - -template -boost::type* target(R (Target::*)(A1,A2) volatile) { return 0; } - -template -boost::type* target(R (Target::*)(A1,A2,A3) volatile) { return 0; } - -// const volatile member functions -template -boost::type* target(R (Target::*)() const volatile) { return 0; } - -template -boost::type* target(R (Target::*)(A1) const volatile) { return 0; } - -template -boost::type* target(R (Target::*)(A1,A2) const volatile) { return 0; } - -template -boost::type* target(R (Target::*)(A1,A2,A3) const volatile) { return 0; } +template +boost::type* target(R (T::*)) { return 0; } }}} // namespace boost::python::detail -#endif // TARGET_DWA2002513_HPP +#endif // TARGET_DWA2002521_HPP diff --git a/include/boost/python/iterator.hpp b/include/boost/python/iterator.hpp index 0f1e8eeb..a31954aa 100644 --- a/include/boost/python/iterator.hpp +++ b/include/boost/python/iterator.hpp @@ -18,15 +18,14 @@ namespace detail // Adds an additional layer of binding to // objects::make_iterator(...), which allows us to pass member // function and member data pointers. - template + template inline ref make_iterator( - Accessor1 get_start, Accessor2 get_finish, NextPolicies* = 0, boost::type* target = 0) + Accessor1 get_start, Accessor2 get_finish, boost::type* target = 0, NextPolicies* = 0) { - return objects::make_iterator_function( + return objects::make_iterator_function( boost::protect(boost::bind(get_start, _1)) , boost::protect(boost::bind(get_finish, _1)) - , (NextPolicies*)0 - , target); + ); } // Guts of template class iterators<>, below. @@ -71,7 +70,9 @@ struct iterators template ref range(Accessor1 start, Accessor2 finish) { - return detail::make_iterator(start, finish, (objects::default_iterator_call_policies*)0, detail::target(start)); + return detail::make_iterator( + start, finish + , detail::target(start)); } // Create an iterator-building function which uses the given accessors @@ -79,7 +80,7 @@ ref range(Accessor1 start, Accessor2 finish) template ref range(Accessor1 start, Accessor2 finish, NextPolicies* = 0) { - return detail::make_iterator(start, finish, (NextPolicies*)0, detail::target(start)); + return detail::make_iterator(start, finish, detail::target(start)); } // Create an iterator-building function which uses the given accessors @@ -88,8 +89,7 @@ template ref range(Accessor1 start, Accessor2 finish, NextPolicies* = 0, boost::type* = 0) { typedef typename add_reference::type target; - return detail::make_iterator(start, finish, (NextPolicies*)0, - (boost::type*)0); + return detail::make_iterator(start, finish); } // A Python callable object which produces an iterator traversing diff --git a/include/boost/python/object/iterator.hpp b/include/boost/python/object/iterator.hpp index 35073438..1319425f 100644 --- a/include/boost/python/object/iterator.hpp +++ b/include/boost/python/object/iterator.hpp @@ -119,7 +119,7 @@ namespace detail // Check the registry. If one is already registered, return it. ref result( - objects::registered_class_object(converter::undecorated_type_id())); + objects::registered_class_object(python::type_id())); if (result.get() == 0) { @@ -189,7 +189,7 @@ namespace detail template inline ref make_iterator_function( Accessor1 const& get_start, Accessor2 const& get_finish - , NextPolicies* , boost::type*) + , boost::type* = 0, NextPolicies* = 0) { typedef typename Accessor1::result_type result_type; diff --git a/include/boost/python/preprocessed/target.hpp b/include/boost/python/preprocessed/target.hpp new file mode 100755 index 00000000..f2a23cee --- /dev/null +++ b/include/boost/python/preprocessed/target.hpp @@ -0,0 +1,402 @@ +template +boost::type*target(R(*)()) +{ + return 0; +} +template +boost::type*target(R(*)(A0)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4,A5)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4,A5,A6)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4,A5,A6,A7)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4,A5,A6,A7,A8)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4,A5,A6,A7,A8,A9)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13)) +{ + return 0; +} +template +boost::type*target(R(*)(A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14)) +{ + return 0; +} + +template +boost::type*target(R(A0::*)()) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14)) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15)) +{ + return 0; +} +template +boost::type*target(R(A0::*)()const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15)const) +{ + return 0; +} +template +boost::type*target(R(A0::*)()volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15)volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)()const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14)const volatile) +{ + return 0; +} +template +boost::type*target(R(A0::*)(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15)const volatile) +{ + return 0; +} +