diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index d7a01edd..e03f1838 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -195,12 +195,11 @@ class class_ : public objects::class_base self& add_property(char const* name, object const& fget); self& add_property(char const* name, object const& fget, object const& fset); - self& setattr(char const* name, object const&); - - template - self& bind(char const* name, T const& x) + template + self& setattr(char const* name, U const& x) { - return this->setattr(name, object(x)); + this->base::setattr(name, object(x)); + return *this; } // Pickle support @@ -293,13 +292,6 @@ inline class_& class_::add_property(char const* name, ob return *this; } -template -inline class_& class_::setattr(char const* name, object const& x) -{ - base::setattr(name, x); - return *this; -} - namespace detail { // This is an mpl BinaryMetaFunction object with a runtime behavior, diff --git a/include/boost/python/object/iterator.hpp b/include/boost/python/object/iterator.hpp index 8590d531..c39131c6 100644 --- a/include/boost/python/object/iterator.hpp +++ b/include/boost/python/object/iterator.hpp @@ -43,9 +43,9 @@ struct default_iterator_call_policies template struct iterator_range { - iterator_range(handle<> sequence, Iterator start, Iterator finish); + iterator_range(object sequence, Iterator start, Iterator finish); - handle<> m_sequence; // Keeps the sequence alive while iterating. + object m_sequence; // Keeps the sequence alive while iterating. Iterator m_start; Iterator m_finish; }; @@ -134,7 +134,7 @@ namespace detail return class_(name) .def("__iter__", identity_function()) - .bind("next", next_function) + .setattr("next", next_function) ; } @@ -173,7 +173,7 @@ namespace detail // Build and convert the iterator_range<>. return cr( iterator_range( - handle<>(python::borrowed(arg0)) + object((python::detail::borrowed_reference)arg0) , get_start(x), get_finish(x))); } }; @@ -210,7 +210,7 @@ inline object make_iterator_function( // template inline iterator_range::iterator_range( - handle<> sequence, Iterator start, Iterator finish) + object sequence, Iterator start, Iterator finish) : m_sequence(sequence), m_start(start), m_finish(finish) { } diff --git a/src/object/class.cpp b/src/object/class.cpp index d5d854dd..4306a684 100644 --- a/src/object/class.cpp +++ b/src/object/class.cpp @@ -299,8 +299,8 @@ namespace objects void class_base::add_property(char const* name, object const& fget) { object property( - python::detail::new_reference( - PyObject_CallFunction((PyObject*)&PyProperty_Type, "O", fget.ptr()))); + (python::detail::new_reference) + PyObject_CallFunction((PyObject*)&PyProperty_Type, "O", fget.ptr())); this->setattr(name, property); } @@ -308,8 +308,8 @@ namespace objects void class_base::add_property(char const* name, object const& fget, object const& fset) { object property( - python::detail::new_reference( - PyObject_CallFunction((PyObject*)&PyProperty_Type, "OO", fget.ptr(), fset.ptr()))); + (python::detail::new_reference) + PyObject_CallFunction((PyObject*)&PyProperty_Type, "OO", fget.ptr(), fset.ptr())); this->setattr(name, property); }