From 673d857bd85b52e44313f1ac944f3475c47bbb96 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 13 May 2002 16:29:43 +0000 Subject: [PATCH] Added setattr() [SVN r13835] --- include/boost/python/class.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index ae1705f6..16f6a4cf 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -168,17 +168,14 @@ class class_ : public objects::class_base { ref fget(make_getter(pm)); ref fset(make_setter(pm)); - this->add_property(name, fget, fset); - return *this; + return this->add_property(name, fget, fset); } // Property creation self& add_property(char const* name, ref const& fget); self& add_property(char const* name, ref const& fget, ref const& fset); - - // return the underlying object -// ref object() const; (implemented in base class) + self& setattr(char const* name, ref const&); private: // types typedef objects::class_id class_id; @@ -256,6 +253,13 @@ inline class_& class_::add_property(char const* name, re return *this; } +template +inline class_& class_::setattr(char const* name, ref const& x) +{ + class_base::setattr(name, x); + return *this; +} + namespace detail { // This is an mpl BinaryMetaFunction object with a runtime behavior,