Skip to content

Commit a278da2

Browse files
committed
correct get_pointer usage
[SVN r21017]
1 parent 37b2bdb commit a278da2

5 files changed

Lines changed: 16 additions & 27 deletions

File tree

include/boost/python/converter/shared_ptr_to_python.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# include <boost/python/refcount.hpp>
1010
# include <boost/python/converter/shared_ptr_deleter.hpp>
1111
# include <boost/shared_ptr.hpp>
12+
# include <boost/get_pointer.hpp>
1213

1314
namespace boost { namespace python { namespace converter {
1415

@@ -18,7 +19,7 @@ PyObject* shared_ptr_to_python(shared_ptr<T> const& x)
1819
if (!x)
1920
return python::detail::none();
2021
else if (shared_ptr_deleter* d = boost::get_deleter<shared_ptr_deleter>(x))
21-
return incref(d->owner.get());
22+
return incref( get_pointer( d->owner ) );
2223
else
2324
return converter::registered<shared_ptr<T> const&>::converters.to_python(&x);
2425
}

include/boost/python/handle.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ template<class T> inline T * get_pointer(python::handle<T> const & p)
148148

149149
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
150150
namespace python {
151+
#else
152+
153+
// We don't want get_pointer above to hide the others
154+
using boost::get_pointer;
155+
151156
#endif
152157

153158
typedef handle<PyTypeObject> type_handle;

include/boost/python/object/make_ptr_instance.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515

1616
namespace boost { namespace python { namespace objects {
1717

18-
# if BOOST_WORKAROUND(__GNUC__, == 2)
19-
// A weird ADL bug prevents this being found
20-
template<class T> T * get_pointer(T * p)
21-
{
22-
return p;
23-
}
24-
# endif
25-
2618
template <class T, class Holder>
2719
struct make_ptr_instance
2820
: make_instance_impl<T, Holder, make_ptr_instance<T,Holder> >
@@ -36,7 +28,6 @@ struct make_ptr_instance
3628
template <class Ptr>
3729
static inline PyTypeObject* get_class_object(Ptr const& x)
3830
{
39-
using ::boost::get_pointer;
4031
return get_class_object_impl(get_pointer(x));
4132
}
4233

include/boost/python/object/pointer_holder.hpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,9 @@
3030
# include <boost/preprocessor/enum_params.hpp>
3131
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
3232

33-
namespace boost { namespace python { namespace objects {
34-
35-
template <class T>
36-
bool is_null(T const& p, ...)
37-
{
38-
return get_pointer(p) == 0;
39-
}
33+
# include <boost/detail/workaround.hpp>
4034

41-
template <class T>
42-
bool is_null(T* p, int)
43-
{
44-
return p == 0;
45-
}
35+
namespace boost { namespace python { namespace objects {
4636

4737
# if BOOST_WORKAROUND(__GNUC__, == 2)
4838
# define BOOST_PYTHON_UNFORWARD_LOCAL(z, n, _) BOOST_PP_COMMA_IF(n) (typename unforward<A##n>::type)objects::do_unforward(a##n,0)
@@ -114,7 +104,7 @@ void* pointer_holder<Pointer, Value>::holds(type_info dst_t)
114104
if (dst_t == python::type_id<Pointer>())
115105
return &this->m_p;
116106

117-
if (objects::is_null(this->m_p, 0))
107+
if (get_pointer(this->m_p) == 0)
118108
return 0;
119109

120110
type_info src_t = python::type_id<Value>();
@@ -128,7 +118,7 @@ void* pointer_holder_back_reference<Pointer, Value>::holds(type_info dst_t)
128118
if (dst_t == python::type_id<Pointer>())
129119
return &this->m_p;
130120

131-
if (objects::is_null(this->m_p, 0))
121+
if (!get_pointer(this->m_p))
132122
return 0;
133123

134124
if (dst_t == python::type_id<held_type>())

include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,13 @@ namespace boost { namespace python { namespace detail {
703703
return p.get();
704704
}
705705

706-
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
707-
namespace python { namespace detail {
706+
#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
707+
// Don't hide these other get_pointer overloads
708+
using boost::python::get_pointer;
709+
using boost::get_pointer;
710+
}} // namespace python::detail
708711
#endif
709712

710-
}} // namespace python::detail
711713
} // namespace boost
712714

713715
#endif // INDEXING_SUITE_DETAIL_JDG20036_HPP

0 commit comments

Comments
 (0)