From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-10-19 03:59:35
----- Original Message -----
> Sorry I wasn't clear in my description, I want to have non-standard
> constructor/constructors for __init__/__del__ function. ie for the
> example below -
> a = A() # in python
> would translate to underlying calls of the form
> A *a = A::instantiate();
> instead of
> A *a = new A;
> and similar for the destructor. Does this make more sense ?
A little more, yes. A simple solution for the constructor is to wrap the
static member function A::instantiate() and expose it at module scope as
simply "A". For the destructor, the source code tells me that you can wrap a
member function as "__del__" and it will be called at the appropriate time.
Of course, it will /not/ replace the object's destructor, but since it runs
first, if the first argument is a boost::python::ref or a PyObject*, I
believe you can ressurect the object by incrementing its refcount.
By the way, I am currently accepting support contracts for consulting on and
development of Boost.Python.
David Abrahams, C++ library designer for hire
C++ Booster (http://www.boost.org)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk