mirror of
https://github.com/boostorg/python.git
synced 2026-01-26 06:42:27 +00:00
Better support for rvalue from-python conversions of shared_ptr:
always return a pointer that holds the owning python object *unless* the python object contains a NULL shared_ptr holder of the right type. [SVN r28947]
This commit is contained in:
@@ -65,7 +65,7 @@ struct pointer_holder : instance_holder
|
||||
private: // types
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(type_info);
|
||||
void* holds(type_info, bool null_ptr_only);
|
||||
|
||||
template <class T>
|
||||
inline void* holds_wrapped(type_info dst_t, wrapper<T>*,T* p)
|
||||
@@ -99,7 +99,7 @@ struct pointer_holder_back_reference : instance_holder
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(type_info);
|
||||
void* holds(type_info, bool null_ptr_only);
|
||||
|
||||
private: // data members
|
||||
Pointer m_p;
|
||||
@@ -120,9 +120,11 @@ inline pointer_holder_back_reference<Pointer,Value>::pointer_holder_back_referen
|
||||
}
|
||||
|
||||
template <class Pointer, class Value>
|
||||
void* pointer_holder<Pointer, Value>::holds(type_info dst_t)
|
||||
void* pointer_holder<Pointer, Value>::holds(type_info dst_t, bool null_ptr_only)
|
||||
{
|
||||
if (dst_t == python::type_id<Pointer>())
|
||||
if (dst_t == python::type_id<Pointer>()
|
||||
&& !(null_ptr_only && get_pointer(this->m_p))
|
||||
)
|
||||
return &this->m_p;
|
||||
|
||||
Value* p = get_pointer(this->m_p);
|
||||
@@ -137,10 +139,12 @@ void* pointer_holder<Pointer, Value>::holds(type_info dst_t)
|
||||
}
|
||||
|
||||
template <class Pointer, class Value>
|
||||
void* pointer_holder_back_reference<Pointer, Value>::holds(type_info dst_t)
|
||||
void* pointer_holder_back_reference<Pointer, Value>::holds(type_info dst_t, bool null_ptr_only)
|
||||
{
|
||||
if (dst_t == python::type_id<Pointer>())
|
||||
return &this->m_p;
|
||||
if (dst_t == python::type_id<Pointer>()
|
||||
&& !(null_ptr_only && get_pointer(this->m_p))
|
||||
)
|
||||
return &this->m_p;
|
||||
|
||||
if (!get_pointer(this->m_p))
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user