mirror of
https://github.com/boostorg/python.git
synced 2026-01-24 06:02:14 +00:00
added set_attribute member function to allow arbitrary Python objects to be added to an extension class.
[SVN r8150]
This commit is contained in:
13
extclass.cpp
13
extclass.cpp
@@ -309,4 +309,17 @@ void ExtensionClassBase::add_getter_method(Function* getter_, const char* name)
|
||||
add_method(getter, (detail::getattr_string() + name + "__").c_str());
|
||||
}
|
||||
|
||||
void ExtensionClassBase::set_attribute(const char* name, PyObject* x_)
|
||||
{
|
||||
Ptr x(x_);
|
||||
set_attribute(name, x);
|
||||
}
|
||||
|
||||
void ExtensionClassBase::set_attribute(const char* name, Ptr x)
|
||||
{
|
||||
dict().set_item(String(name), x);
|
||||
if (PyCallable_Check(x.get()))
|
||||
detail::enable_named_method(this, name);
|
||||
}
|
||||
|
||||
} // namespace py
|
||||
|
||||
Reference in New Issue
Block a user