|
Boost : |
From: Rainer Deyke (root_at_[hidden])
Date: 2001-03-31 23:48:50
----- Original Message -----
From: "David Abrahams" <abrahams_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, March 31, 2001 5:32 PM
Subject: Re: [boost] creating a BPL instance from an existing C++ object.
> This has come up several times. There is a limitation in Boost.Python
which
> makes trying to do what you want dangerous at best. I posted a proposed
> solution at http://groups.yahoo.com/group/boost/message/10144, but given
the
> deafening silence I got as a response, I just keep directing people at the
> section titled "If you can't (afford to) copy the referent, or the pointer
> is non-const" on this page:
> http://www.boost.org/libs/python/doc/pointers.html.
>
> I would happily make the proposed change to Boost.Python, but would like
to
> hear /something/ from users before undertaking any redesign.
There are cases where 'boost::python::owned_by_arg' is inadequate. For
example, consider the following:
// Singleton pattern:
C& get_the_C()
{
static C the_C;
return the_C;
}
// Object not passed to Python through return value:
void outer::f() {
boost::python::callback<void>::call_method(this->self, f,
this->inner_object);
}
// Object retrieved from Python, then passed back through a different
function:
class C {
public:
set_d(D *d) { this->d = d; }
D* get_d() const { return this->d; }
private:
D *d;
};
In conclusion, 'owned_by_arg' would be nice (though by no means vital for me
personally), but a more general solution would be better.
-- Rainer Deyke (root_at_[hidden]) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk