> From: cxx-users-request@lists.sourceforge.net
> Subject: CXX-Users Digest, Vol 10, Issue 5
> To: cxx-users@lists.sourceforge.net
> Date: Sun, 28 Dec 2008 12:09:36 +0000
>
> Send CXX-Users mailing list submissions to
> cxx-users@lists.sourceforge.net
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.sourceforge.net/lists/listinfo/cxx-users
> or, via email, send a message with subject or body 'help' to
> cxx-users-request@lists.sourceforge.net
>
> You can reach the person managing the list at
> cxx-users-owner@lists.sourceforge.net
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of CXX-Users digest..."
>
>
> Today's Topics:
>
> 1. Re:Python objects not deleted (Barry Scott)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 28 Dec 2008 11:00:48 +0000
> From: Barry Scott <barry@barrys-emacs.org>
> Subject: Re: Python objects not deleted
> To: Discuss PyCXX use and improvement
> <cxx-users@lists.sourceforge.net>
> Message-ID: <451B61E0-C99D-47C6-B756-5492C21C607C@barrys-emacs.org>
> Content-Type: text/plain; charset="us-ascii"
>
>
> On 24 Dec 2008, at 00:15, William Newbery wrote:
>
> > > Cannot be done. Python can only call C code that meets its API
> > > specification. C++ loses on two counts its not C and its not
> > python API.
> >
> > I think you missed what I meant. I dont want python to touch that
> > stuff, I want it only for other c++ objects in the same project ie:
> >
> > class Direct3D : public Py::ExtensionObject<Direct3D>
> > {
> > ...
> > Py::Object Render(const Py::Tuple &args);//--- method for use by
> > python
> > ...
> > IDirect3DDevice9* GetDevice();//--- ONLY used by other c++
> > objects in this project, like say the sprite class that needs to do:
> > "d3d->GetDevice()->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2)" etc
> > };
> >
> > So basicly what I'm saying is that within the c++ code can I use the
> > Direct3D* object directly, and ignore the python stuff all together
> > except for maintaining the refrence count so it cant get deleted
> > while its still used by c++ objects. I dont want python to even know
> > about the GetDevice method and IDirect3DDevice9 interface, thats
> > soley for internal use by my c++ project.
>
> The error you made was not letting Python handle the ref counting. Fix
> that as I suggested and you will be good.
>
> If you have private objects that Python does not need to see manage
> them in C++ way.
>
> Barry
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
>
> ------------------------------
>
> ------------------------------------------------------------------------------
>
>
> ------------------------------
>
> _______________________________________________
> CXX-Users mailing list
> CXX-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/cxx-users
>
>
> End of CXX-Users Digest, Vol 10, Issue 5
> ****************************************

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.

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.



Win John Lewis vouchers with BigSnapSearch.com Search now