2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-26 06:42:27 +00:00

Make Dereferenceable use get_pointer

Re-enable map_indexing_suite iteration for vc6.


[SVN r21008]
This commit is contained in:
Dave Abrahams
2003-11-29 22:12:18 +00:00
parent dd7a24ebce
commit e9519db974
6 changed files with 41 additions and 16 deletions

View File

@@ -59,7 +59,7 @@ If <code><b>x</b></code> is not a pointer type, it also must satsify the followi
</tr>
<tr>
<td valign="top"><code>x.get()</code></td>
<td valign="top"><code>get_pointer( x )</code></td>
<td><code>&amp;*x</code>, or a null pointer
</tr>
</table>

View File

@@ -137,6 +137,19 @@ class handle
T* m_p;
};
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
} // namespace python
#endif
template<class T> inline T * get_pointer(python::handle<T> const & p)
{
return p.get();
}
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
namespace python {
#endif
typedef handle<PyTypeObject> type_handle;
//

View File

@@ -10,10 +10,19 @@
# include <boost/python/converter/registry.hpp>
# include <boost/type_traits/is_polymorphic.hpp>
# include <boost/get_pointer.hpp>
# include <boost/detail/workaround.hpp>
# include <typeinfo>
namespace boost { namespace python { namespace objects {
# if BOOST_WORKAROUND(__GNUC__, == 2)
// A weird ADL bug prevents this being found
template<class T> T * get_pointer(T * p)
{
return p;
}
# endif
template <class T, class Holder>
struct make_ptr_instance
: make_instance_impl<T, Holder, make_ptr_instance<T,Holder> >
@@ -27,6 +36,7 @@ struct make_ptr_instance
template <class Ptr>
static inline PyTypeObject* get_class_object(Ptr const& x)
{
using ::boost::get_pointer;
return get_class_object_impl(get_pointer(x));
}

View File

@@ -9,6 +9,7 @@
# ifndef POINTER_HOLDER_DWA20011215_HPP
# define POINTER_HOLDER_DWA20011215_HPP
# include <boost/get_pointer.hpp>
# include <boost/type.hpp>
# include <boost/python/instance_holder.hpp>
@@ -34,7 +35,7 @@ namespace boost { namespace python { namespace objects {
template <class T>
bool is_null(T const& p, ...)
{
return p.get() == 0;
return get_pointer(p) == 0;
}
template <class T>

View File

@@ -9,8 +9,8 @@
# include <boost/python/extract.hpp>
# include <boost/scoped_ptr.hpp>
# include <boost/detail/binary_search.hpp>
# include <boost/get_pointer.hpp>
# include <boost/detail/binary_search.hpp>
# include <vector>
# include <map>
@@ -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 <class Container, class Index, class Policies>
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

View File

@@ -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);