ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
[C++-sig] Re: Python + Boost Python V2 + downcasting
by Nicolas Lelong other posts by this author
Nov 11 2002 4:53PM messages near this date
Re: [C++-sig] Re: Python + Boost Python V2 + downcasting | [C++-sig] () and [] operators
David Abrahams wrote:

>  [digression:
> 
>  I notice that you're using return_internal_reference<>() to return the
>  Base* from the ObjectServer. Does the ObjectServer actually control
>  the lifetime of the objects, or is it simply holding pointers? I ask
>  because I don't see a destructor, so in the code you sent,
>  return_internal_reference<> is inappropriate (maybe you were just
>  eliminating details for the sake of the post?) -- the point of
>  return_internal_reference<> is to keep the owning object alive as long
>  as the owned objects are also alive. If something else is managing
>  their lifetimes, you may need another mechanism.
>  ]

nope, of course the ObjectServer manages the lifetime of the Base objects ;
I just made up a simple example for the post.

>  ...
> 
>  In the meantime, if the ObjectServer is really the owner of the C++
>  objects, you might consider storing boost::python::object in its
>  m_objects array. If you convert your Derived objects to
>  boost::python::object at their point of creation, the full dynamic
>  type will be preserved for Python.

I'll use some other mecanisms for now (such as a collection of functions
that wrap a collection of dynamic_casts - as for my tests I don't need a
full blown solution), as I try to extend Python with existing code and I
like the non-intrusive paradigm.

As for your other points, I'll try to take some time to take a closer look
to all this ... I'll see what I can get playing with custom return value
policies and/or boost/python/object/make_instance.hpp [I'll have a look at
this first, I'd really like to have a 'working' isinstance :) ].

I'll let you know if I have some results !

Thanks for the hints & your help,
Nicolas.

_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved