From 5340194a9af84f9931a8425cc07072a2c3988bd3 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 6 Nov 2000 05:18:55 +0000 Subject: [PATCH] added set_attribute member function to allow arbitrary Python objects to be added to an extension class. [SVN r8150] --- extclass.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/extclass.cpp b/extclass.cpp index 8fb687b9..4fbe9020 100644 --- a/extclass.cpp +++ b/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