Boost logo

Boost-Commit :

From: nickm_at_[hidden]
Date: 2007-09-12 17:31:40


Author: nikiml
Date: 2007-09-12 17:31:39 EDT (Wed, 12 Sep 2007)
New Revision: 39223
URL: http://svn.boost.org/trac/boost/changeset/39223

Log:
fixed problem reported by Neal Becker; added a test case
Text files modified:
   trunk/boost/python/to_python_value.hpp | 4 +++-
   trunk/libs/python/test/shared_ptr.cpp | 17 +++++++++++++++++
   2 files changed, 20 insertions(+), 1 deletions(-)

Modified: trunk/boost/python/to_python_value.hpp
==============================================================================
--- trunk/boost/python/to_python_value.hpp (original)
+++ trunk/boost/python/to_python_value.hpp 2007-09-12 17:31:39 EDT (Wed, 12 Sep 2007)
@@ -106,7 +106,7 @@
     
       PyObject* operator()(argument_type) const;
 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
- PyTypeObject const* get_pytype() const {return get_pytype((boost::type<T>*)0);}
+ PyTypeObject const* get_pytype() const {return get_pytype((boost::type<argument_type>*)0);}
 #endif
       // This information helps make_getter() decide whether to try to
       // return an internal reference or not. I don't like it much,
@@ -115,6 +115,8 @@
   private:
 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
       template <class U>
+ PyTypeObject const* get_pytype(boost::type<shared_ptr<U> &> *) const {return converter::registered<U>::converters.to_python_target_type();}
+ template <class U>
       PyTypeObject const* get_pytype(boost::type<const shared_ptr<U> &> *) const {return converter::registered<U>::converters.to_python_target_type();}
 #endif
   };

Modified: trunk/libs/python/test/shared_ptr.cpp
==============================================================================
--- trunk/libs/python/test/shared_ptr.cpp (original)
+++ trunk/libs/python/test/shared_ptr.cpp 2007-09-12 17:31:39 EDT (Wed, 12 Sep 2007)
@@ -43,6 +43,7 @@
     }
 
     static shared_ptr<T> get() { return storage; }
+ static shared_ptr<T> &get1() { return storage; }
         
     static int look_store()
     {
@@ -71,6 +72,8 @@
             .staticmethod("identity")
             .def("null", &null)
             .staticmethod("null")
+ .def("get1", &get1, return_internal_reference<>())
+ .staticmethod("get1")
             .def("get", &get)
             .staticmethod("get")
             .def("count", &T::count)
@@ -154,6 +157,14 @@
 
 // ------
 
+// from Neal Becker
+
+struct Test {
+ boost::shared_ptr<X> x;
+};
+// ------
+
+
 BOOST_PYTHON_MODULE(shared_ptr_ext)
 {
     class_<A, boost::shared_ptr<A_Wrapper>, boost::noncopyable>("A")
@@ -193,6 +204,12 @@
             .def("value", &Z::value)
             .def("v", &Z::v, &ZWrap::default_v)
         );
+
+// from Neal Becker
+ class_<Test> ("Test")
+ .def_readonly ("x", &Test::x, "x")
+ ;
+// ------
 }
 
 #include "module_tail.cpp"


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk