From e6fd78ce93df37894ee74351ce68e6127f9218ce Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 12 Mar 2004 15:22:16 +0000 Subject: [PATCH] Fixes for auto_ptr handling [SVN r22490] --- include/boost/python/data_members.hpp | 17 ++++-------- .../boost/python/default_call_policies.hpp | 18 +++++++------ include/boost/python/object/forward.hpp | 26 +++++++++---------- include/boost/python/object_core.hpp | 2 ++ include/boost/python/return_arg.hpp | 7 ++--- include/boost/python/return_by_value.hpp | 6 ++--- include/boost/python/to_python_value.hpp | 13 +++------- test/as_to_python_function.cpp | 2 +- 8 files changed, 39 insertions(+), 52 deletions(-) diff --git a/include/boost/python/data_members.hpp b/include/boost/python/data_members.hpp index 733c8b43..7e2366fd 100644 --- a/include/boost/python/data_members.hpp +++ b/include/boost/python/data_members.hpp @@ -19,6 +19,7 @@ # include # include +# include # include # include @@ -51,10 +52,6 @@ namespace detail template struct member { - private: - typedef typename add_const::type data_const; - typedef typename add_reference::type data_cref; - public: member(Data Class::*which) : m_which(which) {} @@ -63,7 +60,7 @@ namespace detail return c.*m_which; } - void operator()(Class& c, data_cref d) const + void operator()(Class& c, typename value_arg::type d) const { c.*m_which = d; } @@ -76,10 +73,6 @@ namespace detail template struct datum { - private: - typedef typename add_const::type data_const; - typedef typename add_reference::type data_cref; - public: datum(Data *which) : m_which(which) {} @@ -88,7 +81,7 @@ namespace detail return *m_which; } - void operator()(data_cref d) const + void operator()(typename value_arg::type d) const { *m_which = d; } @@ -112,11 +105,11 @@ namespace detail : mpl::and_< mpl::bool_< to_python_value< - typename add_reference::type>::type + typename value_arg::type >::uses_registry > , is_reference_to_class< - typename add_reference::type>::type + typename value_arg::type > > { diff --git a/include/boost/python/default_call_policies.hpp b/include/boost/python/default_call_policies.hpp index db4e4cd3..592fe482 100644 --- a/include/boost/python/default_call_policies.hpp +++ b/include/boost/python/default_call_policies.hpp @@ -9,7 +9,11 @@ # include # include # include +# include # include +# include +# include +# include namespace boost { namespace python { @@ -53,14 +57,12 @@ struct default_result_converter template struct apply { - BOOST_STATIC_CONSTANT(bool, is_illegal = is_reference::value || is_pointer::value); - - typedef typename mpl::if_c< - is_illegal - , detail::specify_a_return_value_policy_to_wrap_functions_returning - , boost::python::to_python_value< - typename add_reference::type>::type - > + typedef typename mpl::if_< + mpl::or_, is_reference > + , detail::specify_a_return_value_policy_to_wrap_functions_returning + , boost::python::to_python_value< + typename detail::value_arg::type + > >::type type; }; }; diff --git a/include/boost/python/object/forward.hpp b/include/boost/python/object/forward.hpp index bf21aa2a..a859e77f 100644 --- a/include/boost/python/object/forward.hpp +++ b/include/boost/python/object/forward.hpp @@ -11,10 +11,14 @@ # include # include # include +# include +# include # if BOOST_WORKAROUND(BOOST_MSVC, == 1200) # include # include # include +# else +# include # endif namespace boost { namespace python { namespace objects { @@ -48,7 +52,7 @@ struct forward > > # else - is_scalar + mpl::or_, is_scalar > # endif , T , reference_to_value @@ -71,10 +75,8 @@ struct unforward > template struct unforward_cref - : add_reference< - typename add_const< - typename unwrap_reference::type - >::type + : python::detail::value_arg< + typename unwrap_reference::type > { }; @@ -122,10 +124,8 @@ namespace detail { template struct apply - : add_reference< - typename add_const< - typename unwrap_reference::type - >::type + : python::detail::value_arg< + typename unwrap_reference::type > { }; @@ -136,11 +136,9 @@ namespace detail { template struct apply - : add_reference< - typename add_const< - typename T::reference - >::type - > + : python::detail::value_arg< + typename T::reference + > { }; }; diff --git a/include/boost/python/object_core.hpp b/include/boost/python/object_core.hpp index eb37f71f..dcced44f 100755 --- a/include/boost/python/object_core.hpp +++ b/include/boost/python/object_core.hpp @@ -176,6 +176,8 @@ namespace api # endif private: // def visitation for adding callable objects as class methods + using def_visitor::visit; + template void visit(ClassT& cl, char const* name, python::detail::def_helper const& helper) const { diff --git a/include/boost/python/return_arg.hpp b/include/boost/python/return_arg.hpp index 7abe3559..93c1cada 100755 --- a/include/boost/python/return_arg.hpp +++ b/include/boost/python/return_arg.hpp @@ -7,6 +7,7 @@ # define RETURN_ARG_DWA2003719_HPP # include # include +# include # include # include @@ -40,11 +41,7 @@ namespace detail return true; } - PyObject *operator()( - typename add_reference< - typename add_const::type - >::type - ) const + PyObject *operator()( typename value_arg::type ) const { return none(); } diff --git a/include/boost/python/return_by_value.hpp b/include/boost/python/return_by_value.hpp index dba6736f..c380098f 100644 --- a/include/boost/python/return_by_value.hpp +++ b/include/boost/python/return_by_value.hpp @@ -12,6 +12,8 @@ # include # include +# include + namespace boost { namespace python { struct return_by_value @@ -20,9 +22,7 @@ struct return_by_value struct apply { typedef to_python_value< - typename add_reference< - typename add_const::type - >::type + typename detail::value_arg::type > type; }; }; diff --git a/include/boost/python/to_python_value.hpp b/include/boost/python/to_python_value.hpp index f726ec9e..24b8dbb5 100644 --- a/include/boost/python/to_python_value.hpp +++ b/include/boost/python/to_python_value.hpp @@ -19,6 +19,7 @@ # include # include +# include # include @@ -32,9 +33,7 @@ namespace detail template struct object_manager_to_python_value { - typedef typename add_reference< - typename add_const::type - >::type argument_type; + typedef typename value_arg::type argument_type; PyObject* operator()(argument_type) const; @@ -48,9 +47,7 @@ namespace detail template struct registry_to_python_value { - typedef typename add_reference< - typename add_const::type - >::type argument_type; + typedef typename value_arg::type argument_type; PyObject* operator()(argument_type) const; @@ -63,9 +60,7 @@ namespace detail template struct shared_ptr_to_python_value { - typedef typename add_reference< - typename add_const::type - >::type argument_type; + typedef typename value_arg::type argument_type; PyObject* operator()(argument_type) const; diff --git a/test/as_to_python_function.cpp b/test/as_to_python_function.cpp index 814749d1..f469d418 100644 --- a/test/as_to_python_function.cpp +++ b/test/as_to_python_function.cpp @@ -4,7 +4,7 @@ // "as is" without express or implied warranty, and with no claim as // to its suitability for any purpose. -#include +#include struct hopefully_illegal {