diff --git a/doc/v2/class.html b/doc/v2/class.html index f7bc46db..1c84c1c2 100644 --- a/doc/v2/class.html +++ b/doc/v2/class.html @@ -223,7 +223,7 @@ namespace boost { namespace python class_& def_init(Args const& = Args()); template <class Args, class CallPolicy> - self& def_init(Args const&, CallPolicy policy); + class_& def_init(Args const&, CallPolicy policy); // exposing member functions template <class F> @@ -234,10 +234,13 @@ namespace boost { namespace python // exposing data members template <class D> - self& def_readonly(char const* name, D T::*pm); + class_& def_readonly(char const* name, D T::*pm); template <class D> - self& def_readwrite(char const* name, D T::*pm); + class_& def_readwrite(char const* name, D T::*pm); + + // Raw attribute modification + class_& setattr(char const* name, ref const&); // property creation void add_property(char const* name, ref const& fget); @@ -339,9 +342,11 @@ class_& def(char const* name, Fn f, CallPolicies policies);
-
Requires: f is a non-null pointer-to-function or - pointer-to-member-function. name is a ntbs which conforms to - Python's Requires: f is a non-null + pointer-to-function or pointer-to-member-function, or a callable + Python object passed as a PyObject* or ref. name + is a ntbs which conforms to Python's identifier naming rules. In the first form, the return type of f is not a reference and is not a pointer other @@ -350,7 +355,8 @@ class_& def(char const* name, Fn f, CallPolicies policies); href="CallPolicies.html">CallPolicies.
Effects: Adds the result of make_function(f) to + "make_function.html#make_function-spec">make_function(f) or make_function(f, policies) to the Boost.Python extension class being defined, with the given name. If the extension class already has an attribute named name, the usual Returns: *this
+
+template <class F>
+class_& setattr(char const* name, ref x);
+
+ +
+
Requires: name is a ntbs which conforms to + Python's identifier + naming rules. + +
Effects: PyObject_SetAttrString(this->object(), name, x.get()); + +
Returns: *this +
+
-void add_property(char const* name, ref const&amp; fget);
-void add_property(char const* name, ref const&amp; fget, ref const&amp; fset);
+void add_property(char const* name, ref const& fget);
+void add_property(char const* name, ref const& fget, ref const& fset);
 
@@ -389,7 +411,7 @@ void add_property(char const* name, ref const&amp; fget, ref const&amp;
     template <class D>
-    self& def_readonly(char const* name, D T::*pm);
+    class_& def_readonly(char const* name, D T::*pm);
 
@@ -415,7 +437,7 @@ this->add_property(name, ref(mak
 template <class D>
-self& def_readwrite(char const* name, D T::*pm);
+class_& def_readwrite(char const* name, D T::*pm);
 
diff --git a/include/boost/python/object/class.hpp b/include/boost/python/object/class.hpp index 10c54629..4d8d3bbe 100644 --- a/include/boost/python/object/class.hpp +++ b/include/boost/python/object/class.hpp @@ -39,10 +39,13 @@ struct BOOST_PYTHON_DECL class_base : private noncopyable ref object() const { return m_object; } void add_property(char const* name, ref const& fget); void add_property(char const* name, ref const& fget, ref const& fset); + void setattr(char const* name, ref const&); private: ref m_object; }; +BOOST_PYTHON_DECL ref registered_class_object(class_id id); + // Base class for all holders struct BOOST_PYTHON_DECL instance_holder : private noncopyable {