2
0
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:
Dave Abrahams
2000-11-06 05:18:55 +00:00
parent 6eb7524d03
commit 5340194a9a

View File

@@ -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