2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-22 05:22:45 +00:00

back_reference<> uses object instead of handle<>

[SVN r14600]
This commit is contained in:
Dave Abrahams
2002-07-25 15:20:06 +00:00
parent 8763fd1c53
commit 30ef9c6418
3 changed files with 10 additions and 8 deletions

View File

@@ -7,6 +7,7 @@
# define BACK_REFERENCE_DWA2002510_HPP
# include <boost/python/handle.hpp>
# include <boost/python/object_core.hpp>
namespace boost { namespace python {
@@ -17,10 +18,10 @@ struct back_reference
typedef T type;
back_reference(PyObject*, T);
handle<> reference() const;
object const& source() const;
T get() const;
private:
handle<> m_reference;
object m_source;
T m_value;
};
@@ -75,15 +76,15 @@ class is_back_reference
//
template <class T>
back_reference<T>::back_reference(PyObject* p, T x)
: m_reference(python::borrowed(p))
: m_source(detail::borrowed_reference(p))
, m_value(x)
{
}
template <class T>
handle<> back_reference<T>::reference() const
object const& back_reference<T>::source() const
{
return m_reference;
return m_source;
}
template <class T>

View File

@@ -15,6 +15,7 @@
# include <boost/python/self.hpp>
# include <boost/python/other.hpp>
# include <boost/lexical_cast.hpp>
# include <boost/python/refcount.hpp>
# include <string>
# include <complex>
@@ -251,7 +252,7 @@ namespace detail \
execute(back_reference<L&> l, R const& r) \
{ \
l.get() op r; \
return l.reference().release(); \
return python::incref(l.source().ptr()); \
} \
}; \
static char const* name() { return "__" #id "__"; } \

View File

@@ -75,9 +75,9 @@ namespace boost { namespace python
}}
// prove that back_references get initialized with the right PyObject*
PyObject* y_identity(back_reference<Y const&> y)
object y_identity(back_reference<Y const&> y)
{
return y.reference().release();
return y.source();
}
// prove that back_references contain the right value