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:
@@ -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>
|
||||
|
||||
@@ -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 "__"; } \
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user