From e9519db97438e069742cd5ae7b1670e50a32e2e3 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 29 Nov 2003 22:12:18 +0000 Subject: [PATCH] Make Dereferenceable use get_pointer Re-enable map_indexing_suite iteration for vc6. [SVN r21008] --- doc/v2/Dereferenceable.html | 2 +- include/boost/python/handle.hpp | 13 +++++++++++ .../boost/python/object/make_ptr_instance.hpp | 10 ++++++++ .../boost/python/object/pointer_holder.hpp | 3 ++- .../indexing/detail/indexing_suite_detail.hpp | 23 ++++++++++++------- .../python/suite/indexing/indexing_suite.hpp | 6 ----- 6 files changed, 41 insertions(+), 16 deletions(-) diff --git a/doc/v2/Dereferenceable.html b/doc/v2/Dereferenceable.html index fdea0fc0..43a56a0a 100644 --- a/doc/v2/Dereferenceable.html +++ b/doc/v2/Dereferenceable.html @@ -59,7 +59,7 @@ If x is not a pointer type, it also must satsify the followi - x.get() + get_pointer( x ) &*x, or a null pointer diff --git a/include/boost/python/handle.hpp b/include/boost/python/handle.hpp index fee589bf..338cd3c2 100755 --- a/include/boost/python/handle.hpp +++ b/include/boost/python/handle.hpp @@ -137,6 +137,19 @@ class handle T* m_p; }; +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +} // namespace python +#endif + +template inline T * get_pointer(python::handle const & p) +{ + return p.get(); +} + +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +namespace python { +#endif + typedef handle type_handle; // diff --git a/include/boost/python/object/make_ptr_instance.hpp b/include/boost/python/object/make_ptr_instance.hpp index 169106f4..a69afab3 100644 --- a/include/boost/python/object/make_ptr_instance.hpp +++ b/include/boost/python/object/make_ptr_instance.hpp @@ -10,10 +10,19 @@ # include # include # include +# include # include namespace boost { namespace python { namespace objects { +# if BOOST_WORKAROUND(__GNUC__, == 2) +// A weird ADL bug prevents this being found +template T * get_pointer(T * p) +{ + return p; +} +# endif + template struct make_ptr_instance : make_instance_impl > @@ -27,6 +36,7 @@ struct make_ptr_instance template static inline PyTypeObject* get_class_object(Ptr const& x) { + using ::boost::get_pointer; return get_class_object_impl(get_pointer(x)); } diff --git a/include/boost/python/object/pointer_holder.hpp b/include/boost/python/object/pointer_holder.hpp index cc114925..4868c58a 100644 --- a/include/boost/python/object/pointer_holder.hpp +++ b/include/boost/python/object/pointer_holder.hpp @@ -9,6 +9,7 @@ # ifndef POINTER_HOLDER_DWA20011215_HPP # define POINTER_HOLDER_DWA20011215_HPP +# include # include # include @@ -34,7 +35,7 @@ namespace boost { namespace python { namespace objects { template bool is_null(T const& p, ...) { - return p.get() == 0; + return get_pointer(p) == 0; } template diff --git a/include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp b/include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp index 10aa0954..4d192a49 100644 --- a/include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp +++ b/include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp @@ -9,8 +9,8 @@ # include # include -# include # include +# include # include # include @@ -366,9 +366,9 @@ namespace boost { namespace python { namespace detail { } container_element(container_element const& ce) - : ptr(ce.ptr.get() == 0 ? 0 : new element_type(*ce.ptr.get())) - , container(ce.container) - , index(ce.index) + : ptr(ce.ptr.get() == 0 ? 0 : new element_type(*ce.ptr.get())) + , container(ce.container) + , index(ce.index) { } @@ -381,14 +381,14 @@ namespace boost { namespace python { namespace detail { element_type& operator*() const { if (is_detached()) - return *ptr.get(); + return *get_pointer(ptr); return Policies::get_item(get_container(), index); } element_type* get() const { if (is_detached()) - return ptr.get(); + return get_pointer(ptr); return &Policies::get_item(get_container(), index); } @@ -407,7 +407,7 @@ namespace boost { namespace python { namespace detail { bool is_detached() const { - return ptr.get() != 0; + return get_pointer(ptr) != 0; } Container& @@ -690,7 +690,9 @@ namespace boost { namespace python { namespace detail { } }; - }} // namespace python::detail +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +}} // namespace python::detail +#endif template inline typename Policies::data_type* @@ -701,6 +703,11 @@ namespace boost { namespace python { namespace detail { return p.get(); } +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP +namespace python { namespace detail { +#endif + +}} // namespace python::detail } // namespace boost #endif // INDEXING_SUITE_DETAIL_JDG20036_HPP diff --git a/include/boost/python/suite/indexing/indexing_suite.hpp b/include/boost/python/suite/indexing/indexing_suite.hpp index e2dc4a85..1e392b40 100644 --- a/include/boost/python/suite/indexing/indexing_suite.hpp +++ b/include/boost/python/suite/indexing/indexing_suite.hpp @@ -182,13 +182,7 @@ namespace boost { namespace python { .def("__delitem__", &base_delete_item) .def("__getitem__", &base_get_item) .def("__contains__", &base_contains) - -#if !defined(BOOST_MSVC) || BOOST_MSVC > 1200 -// crazy VC6 doesn't like this! perhaps there's a better -// fix but this one will do for now. def __iter__ is just -// an optimization anyway. .def("__iter__", def_iterator()) -#endif ; DerivedPolicies::extension_def(cl);