mirror of
https://github.com/boostorg/python.git
synced 2026-01-24 18:12:43 +00:00
Fixed some technical problems with smart pointer support uncovered by
STLPort's debug mode. Unfortunately, had to expand Dereferenceable requirements. [SVN r16459]
This commit is contained in:
@@ -49,10 +49,25 @@ type is a model of Dereferenceable.
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
If <code><b>x</b></code> is not a pointer type, it also must satsify the following expression:
|
||||
|
||||
<table summary="Dereferenceable expressions" border="1" cellpadding="5">
|
||||
|
||||
<tr>
|
||||
<td><b>Expression</b></td>
|
||||
<td><b>Operational Semantics</b></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><code>x.get()</code></td>
|
||||
<td><code>&*x</code>, or a null pointer
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
13 November, 2002
|
||||
29 November, 2002
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||
</p>
|
||||
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||
|
||||
@@ -32,6 +32,18 @@
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
template <class T>
|
||||
typename bool is_null(T const& p, ...)
|
||||
{
|
||||
return p.get() == 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool is_null(T* p, int)
|
||||
{
|
||||
return p == 0;
|
||||
}
|
||||
|
||||
# define BOOST_PYTHON_UNFORWARD_LOCAL(z, n, _) BOOST_PP_COMMA_IF(n) (typename unforward<A##n>::type)(a##n)
|
||||
|
||||
template <class Pointer, class Value>
|
||||
@@ -98,9 +110,12 @@ 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))
|
||||
return 0;
|
||||
|
||||
type_info src_t = python::type_id<Value>();
|
||||
return src_t == dst_t ? &*this->m_p
|
||||
: find_dynamic_type(&*this->m_p, src_t, dst_t);
|
||||
Value* p = &*this->m_p;
|
||||
return src_t == dst_t ? p : find_dynamic_type(p, src_t, dst_t);
|
||||
}
|
||||
|
||||
template <class Pointer, class Value>
|
||||
@@ -109,6 +124,9 @@ 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))
|
||||
return 0;
|
||||
|
||||
if (dst_t == python::type_id<held_type>())
|
||||
return &*this->m_p;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user