mirror of
https://github.com/boostorg/python.git
synced 2026-01-26 06:42:27 +00:00
correct get_pointer usage
[SVN r21017]
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
# include <boost/python/refcount.hpp>
|
||||
# include <boost/python/converter/shared_ptr_deleter.hpp>
|
||||
# include <boost/shared_ptr.hpp>
|
||||
# include <boost/get_pointer.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
|
||||
@@ -18,7 +19,7 @@ PyObject* shared_ptr_to_python(shared_ptr<T> const& x)
|
||||
if (!x)
|
||||
return python::detail::none();
|
||||
else if (shared_ptr_deleter* d = boost::get_deleter<shared_ptr_deleter>(x))
|
||||
return incref(d->owner.get());
|
||||
return incref( get_pointer( d->owner ) );
|
||||
else
|
||||
return converter::registered<shared_ptr<T> const&>::converters.to_python(&x);
|
||||
}
|
||||
|
||||
@@ -148,6 +148,11 @@ template<class T> inline T * get_pointer(python::handle<T> const & p)
|
||||
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
namespace python {
|
||||
#else
|
||||
|
||||
// We don't want get_pointer above to hide the others
|
||||
using boost::get_pointer;
|
||||
|
||||
#endif
|
||||
|
||||
typedef handle<PyTypeObject> type_handle;
|
||||
|
||||
@@ -15,14 +15,6 @@
|
||||
|
||||
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> >
|
||||
@@ -36,7 +28,6 @@ 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));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,20 +30,10 @@
|
||||
# include <boost/preprocessor/enum_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
template <class T>
|
||||
bool is_null(T const& p, ...)
|
||||
{
|
||||
return get_pointer(p) == 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool is_null(T* p, int)
|
||||
{
|
||||
return p == 0;
|
||||
}
|
||||
|
||||
# if BOOST_WORKAROUND(__GNUC__, == 2)
|
||||
# define BOOST_PYTHON_UNFORWARD_LOCAL(z, n, _) BOOST_PP_COMMA_IF(n) (typename unforward<A##n>::type)objects::do_unforward(a##n,0)
|
||||
# else
|
||||
@@ -114,7 +104,7 @@ void* pointer_holder<Pointer, Value>::holds(type_info dst_t)
|
||||
if (dst_t == python::type_id<Pointer>())
|
||||
return &this->m_p;
|
||||
|
||||
if (objects::is_null(this->m_p, 0))
|
||||
if (get_pointer(this->m_p) == 0)
|
||||
return 0;
|
||||
|
||||
type_info src_t = python::type_id<Value>();
|
||||
@@ -128,7 +118,7 @@ void* pointer_holder_back_reference<Pointer, Value>::holds(type_info dst_t)
|
||||
if (dst_t == python::type_id<Pointer>())
|
||||
return &this->m_p;
|
||||
|
||||
if (objects::is_null(this->m_p, 0))
|
||||
if (!get_pointer(this->m_p))
|
||||
return 0;
|
||||
|
||||
if (dst_t == python::type_id<held_type>())
|
||||
|
||||
@@ -703,11 +703,13 @@ namespace boost { namespace python { namespace detail {
|
||||
return p.get();
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
namespace python { namespace detail {
|
||||
#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
// Don't hide these other get_pointer overloads
|
||||
using boost::python::get_pointer;
|
||||
using boost::get_pointer;
|
||||
}} // namespace python::detail
|
||||
#endif
|
||||
|
||||
}} // namespace python::detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // INDEXING_SUITE_DETAIL_JDG20036_HPP
|
||||
|
||||
Reference in New Issue
Block a user