Re: [C++-sig] weak_ptr to this in C++ classes extended from python

2012-04-23 Thread Jim Bosch
On 04/22/2012 03:42 PM, Holger Brandsmeier wrote: Dear list, how is it possible to have a class in C++ that can be extended from python and that stores a weak_ptr to itself? The reason why I want to do this: - using a weak_ptr to itself does not introduce a memory leak. - from a C++-member

Re: [C++-sig] boost::python: marshalling buffers

2012-04-23 Thread Jim Bosch
On 04/18/2012 01:57 PM, Christoph Rupp wrote: Hi, i have a C++ class that i'm wrapping with boost::python: class Foo { // ... const char *get_buffer(); size_t get_size() const; // ... }; I want to send this class through a thrift interface (which uses the write() method to send the

Re: [C++-sig] boost python writing converters for list to std::vector

2012-04-23 Thread Jim Bosch
On 04/20/2012 11:45 AM, Helfer Thomas wrote: Hi, using http://misspent.wordpress.com/2009/09/27/how-to-write-boost-python-converters/, I tried to write a converter for list to std::vector (In the example, T will be double). The code (see converter.cxx) I wrote is still in early stage of deve

Re: [C++-sig] weak_ptr to this in C++ classes extended from python

2012-04-23 Thread Dave Abrahams
on Sun Apr 22 2012, Holger Brandsmeier wrote: > Dear list, > > how is it possible to have a class in C++ that can be extended from > python and that stores a weak_ptr to itself? Easy, I think: just like any other class you wrap. Are you aware of boost::enable_shared_from_this? It does all of

[C++-sig] Boost Python exceptions cannot be pickled

2012-04-23 Thread Faheem Mitha
Hi, Briefly, when using the multiprocessing module, when exceptions are thrown, they need to be pickleable in order to propagate, since that is how multiprocessing passes information around. See http://stackoverflow.com/questions/8785899/hang-in-python-script-using-sqlalchemy-and-multiproce

Re: [C++-sig] weak_ptr to this in C++ classes extended from python

2012-04-23 Thread Holger Brandsmeier
Dear Dave, dear Jim, thanks for your help in particular to `boost::enable_shared_from_this` which I wasn't aware about in the beginning. Unfortunately your solutions did not yet work. In the meantime I figured out a different way of doing the shared pointer from this in python. Namely, to just ma

Re: [C++-sig] weak_ptr to this in C++ classes extended from python

2012-04-23 Thread Dave Abrahams
on Mon Apr 23 2012, Holger Brandsmeier wrote: > In fact the statement > class_, boost::noncopyable >>("I", init<>() ) > has an issue. When I call getThisRCP() later, and the return value is > not a null shared pointer, then I in fact the error > TypeError: No to_python (by-value) converter fou

Re: [C++-sig] weak_ptr to this in C++ classes extended from python

2012-04-23 Thread Holger Brandsmeier
Dave, Here is the reduced example with only the `boost::enable_shared_from_this` variant. The issues are all as reported before. -Holger On Mon, Apr 23, 2012 at 22:25, Dave Abrahams wrote: > > on Mon Apr 23 2012, Holger Brandsmeier wrote: > >> In fact the statement >>   class_, boost::noncopya

Re: [C++-sig] No automatic upcasting with std::shared_ptr in function calls?

2012-04-23 Thread Jim Bosch
On 04/20/2012 03:55 AM, VáclavŠmilauer wrote: Hello, I have a sample hierarchy of polymorphic classes (A from which B inherits). One of them (A1, B1) is managed with boost::shared_ptr, the other one (A2, B2) via std::shared_ptr (I defined the get_pointer template for std::shared_ptr). When I ca