mirror of
https://github.com/boostorg/python.git
synced 2026-01-26 18:52:26 +00:00
Added setattr()
[SVN r13841]
This commit is contained in:
@@ -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);
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Requires:</b> <code>f</code> is a non-null pointer-to-function or
|
||||
pointer-to-member-function. <code>name</code> is a ntbs which conforms to
|
||||
Python's <a href=
|
||||
<dt><b>Requires:</b> <code>f</code> is a non-null
|
||||
pointer-to-function or pointer-to-member-function, or a callable
|
||||
Python object passed as a <code>PyObject*</code> or <a
|
||||
href="reference_hpp.html#ref-spec"><code>ref</code></a>. <code>name</code>
|
||||
is a ntbs which conforms to Python's <a href=
|
||||
"http://www.python.org/doc/2.2/ref/identifiers.html">identifier
|
||||
naming rules</a>. In the first form, the return type of
|
||||
<code>f</code> 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</a>.
|
||||
|
||||
<dt><b>Effects:</b> Adds the result of <code><a href=
|
||||
"make_function.html#make_function-spec">make_function</a>(f)</code> to
|
||||
"make_function.html#make_function-spec">make_function</a>(f)</code> or <code><a href=
|
||||
"make_function.html#make_function-spec">make_function</a>(f, policies)</code> to
|
||||
the Boost.Python extension class being defined, with the given
|
||||
<code>name</code>. If the extension class already has an attribute named
|
||||
<code><i>name</i></code>, the usual <a href=
|
||||
@@ -359,11 +365,27 @@ class_& def(char const* name, Fn f, CallPolicies policies);
|
||||
<dt><b>Returns:</b> <code>*this</code>
|
||||
</dl>
|
||||
|
||||
<pre>
|
||||
template <class F>
|
||||
class_& setattr(char const* name, ref x);
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Requires:</b> <code>name</code> is a ntbs which conforms to
|
||||
Python's <a href=
|
||||
"http://www.python.org/doc/2.2/ref/identifiers.html">identifier
|
||||
naming rules</a>.
|
||||
|
||||
<dt><b>Effects:</b> <code><a href="http://www.python.org/doc/current/api/object.html#l2h-166">PyObject_SetAttrString</a>(this->object(), name, x.get());</code>
|
||||
|
||||
<dt><b>Returns:</b> <code>*this</code>
|
||||
</dl>
|
||||
|
||||
<br>
|
||||
|
||||
<pre>
|
||||
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);
|
||||
</pre>
|
||||
<dl class="function-semantics">
|
||||
|
||||
@@ -389,7 +411,7 @@ void add_property(char const* name, ref const&amp; fget, ref const&amp;
|
||||
<br>
|
||||
<pre>
|
||||
template <class D>
|
||||
self& def_readonly(char const* name, D T::*pm);
|
||||
class_& def_readonly(char const* name, D T::*pm);
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
@@ -415,7 +437,7 @@ this->add_property(name, ref(<a href="data_members.html#make_getter-spec">mak
|
||||
|
||||
<pre>
|
||||
template <class D>
|
||||
self& def_readwrite(char const* name, D T::*pm);
|
||||
class_& def_readwrite(char const* name, D T::*pm);
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user