Skip to content

Commit 30ef9c6

Browse files
committed
back_reference<> uses object instead of handle<>
[SVN r14600]
1 parent 8763fd1 commit 30ef9c6

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

include/boost/python/back_reference.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# define BACK_REFERENCE_DWA2002510_HPP
88

99
# include <boost/python/handle.hpp>
10+
# include <boost/python/object_core.hpp>
1011

1112
namespace boost { namespace python {
1213

@@ -17,10 +18,10 @@ struct back_reference
1718
typedef T type;
1819

1920
back_reference(PyObject*, T);
20-
handle<> reference() const;
21+
object const& source() const;
2122
T get() const;
2223
private:
23-
handle<> m_reference;
24+
object m_source;
2425
T m_value;
2526
};
2627

@@ -75,15 +76,15 @@ class is_back_reference
7576
//
7677
template <class T>
7778
back_reference<T>::back_reference(PyObject* p, T x)
78-
: m_reference(python::borrowed(p))
79+
: m_source(detail::borrowed_reference(p))
7980
, m_value(x)
8081
{
8182
}
8283

8384
template <class T>
84-
handle<> back_reference<T>::reference() const
85+
object const& back_reference<T>::source() const
8586
{
86-
return m_reference;
87+
return m_source;
8788
}
8889

8990
template <class T>

include/boost/python/operators2.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# include <boost/python/self.hpp>
1616
# include <boost/python/other.hpp>
1717
# include <boost/lexical_cast.hpp>
18+
# include <boost/python/refcount.hpp>
1819
# include <string>
1920
# include <complex>
2021

@@ -251,7 +252,7 @@ namespace detail \
251252
execute(back_reference<L&> l, R const& r) \
252253
{ \
253254
l.get() op r; \
254-
return l.reference().release(); \
255+
return python::incref(l.source().ptr()); \
255256
} \
256257
}; \
257258
static char const* name() { return "__" #id "__"; } \

test/back_reference.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ namespace boost { namespace python
7575
}}
7676

7777
// prove that back_references get initialized with the right PyObject*
78-
PyObject* y_identity(back_reference<Y const&> y)
78+
object y_identity(back_reference<Y const&> y)
7979
{
80-
return y.reference().release();
80+
return y.source();
8181
}
8282

8383
// prove that back_references contain the right value

0 commit comments

Comments
 (0)