mirror of
https://github.com/boostorg/python.git
synced 2026-01-22 17:32:55 +00:00
added "add" member function to ClassWrapper<> to allow arbitrary Python
objects to be added to an extension class. [SVN r8142]
This commit is contained in:
@@ -5,13 +5,10 @@
|
||||
#include "module.h"
|
||||
#include "py.h"
|
||||
#include "cast.h"
|
||||
#include "pyptr.h"
|
||||
|
||||
namespace py {
|
||||
|
||||
namespace detail {
|
||||
struct EmptyBase {};
|
||||
}
|
||||
|
||||
// Syntactic sugar to make wrapping classes more convenient
|
||||
template <class T, class U = HeldInstance<T> >
|
||||
class ClassWrapper
|
||||
@@ -103,7 +100,13 @@ class ClassWrapper
|
||||
{
|
||||
return m_class.get();
|
||||
}
|
||||
|
||||
|
||||
// set an arbitrary attribute. Useful for non-function class data members,
|
||||
// e.g. enums
|
||||
void add(PyObject* x, const char* name)
|
||||
{ return m_class->set_attribute(name, x); }
|
||||
void add(Ptr x, const char* name)
|
||||
{ return m_class->set_attribute(name, x); }
|
||||
private:
|
||||
PyPtr<ExtensionClass<T, U> > m_class;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user