|
From: Barry S. <ba...@ba...> - 2008-12-30 11:12:47
|
>
It seems that your questions are not about python C++ but about how to
control object life time.
PyCXX is not going to solve your C++ object life time issues.
What I think you are saying is that when the python object is deleted
the C++ objects it uses may need to live longer.
You need to find a solution to your object life time problems. There
are smart pointer classes that will help
with your object life time issues. But its not PyCXX goal to solve
that problem, only the Python interface problem.
> Ok but how exactly do I do that since the class has both c++ and
> python stuff?
> If I pass a pointer around to the object in the c++ code then either
> the object will get deleted before I want (ie when theres no python
> stuff refrencing it anymore), or it never gets deleted it seems, and
> if I use the extesion object template class to hold the pointer then
> I cant access the c++ stuff.
You can start with the python object and then get the C++ object that
implements it:
ExtensionObject<MyClass> obj( args[0] ); // exception thrown
if wrong type
MyClass *p = obj.extensionObject(); // get C++ pointer
>
>
> Is there some other class that just acts as a smart pointer, allows
> me to access my c++ class directly with -> but also handles the
> stuff python needs like refrence counting.
Barry
|