Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-21 Thread Nat Goodspeed
peoro wrote: There should be no need of dynamic_cast or any kind of run time type checking since the program has got static knowledge of types: The C++ program may have that knowledge. All I'm saying is that your original issue concerned Python determining the runtime type (leaf class) of e

Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-21 Thread peoro
The code I'm trying to wrap doesn't rely on RTTI, that's why there are no virtual functions. (I agree that RTTI would be better from about any point of view, but this piece of software isn't using it) There should be no need of dynamic_cast or any kind of run time type checking since the program h

Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-21 Thread Nat Goodspeed
peoro wrote: Ok, it does work as expected if class Base has got at least one virtual member: ...What if I cannot add a virtual function to the class Base? If your C++ base class has no virtual methods, even pure C++ can't dynamic_cast<> it. Put differently -- you've been asking Python to d

Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-21 Thread Roman Yakovenko
On Sun, Mar 21, 2010 at 4:12 PM, peoro wrote: > Ok, it does work as expected if class Base has got at least one virtual > member: > > from shared_ptr_inheritance import * > type( base1() ) -> Base > type( base2() ) -> Derived > type( derived1() ) -> Derived > type( base3( derived1() ) ) -> Derive

Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-21 Thread peoro
Ok, it does work as expected if class Base has got at least one virtual member: from shared_ptr_inheritance import * type( base1() ) -> Base type( base2() ) -> Derived type( derived1() ) -> Derived type( base3( derived1() ) ) -> Derived type( derived2( base2() ) ) -> Derived Anyhow it looks like

Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-20 Thread Roman Yakovenko
On Sun, Mar 21, 2010 at 4:07 AM, peoro wrote: > Yes, having all of the objects at their most-derived type would be > what I need, but it's not what happens. > > I posted a piece of C++ code that shows what I do (I exported it using > py++ without any further modification): all of the pointers my >

Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-20 Thread Jim Bosch
On Sun, 2010-03-21 at 03:07 +0100, peoro wrote: > Yes, having all of the objects at their most-derived type would be > what I need, but it's not what happens. > > I posted a piece of C++ code that shows what I do (I exported it using > py++ without any further modification): all of the pointers my

Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-20 Thread peoro
Yes, having all of the objects at their most-derived type would be what I need, but it's not what happens. I posted a piece of C++ code that shows what I do (I exported it using py++ without any further modification): all of the pointers my functions return are wrapped in boost::shared_ptr's, but

Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-20 Thread Jim Bosch
On Sat, 2010-03-20 at 21:31 +0100, peoro wrote: > Hello, > > I'm having some issues with shared_ptr's in a Python environment: it > looks like once a shared_ptr enters Python, it cannot be upcasted nor > downcasted. > > Here's a brief C++ source code to explain better the issue: > > > #include

[C++-sig] [Py++] boost::shared_ptr casting

2010-03-20 Thread peoro
Hello, I'm having some issues with shared_ptr's in a Python environment: it looks like once a shared_ptr enters Python, it cannot be upcasted nor downcasted. Here's a brief C++ source code to explain better the issue: #include class Base { }; class Derived : public Base { }; boost::shared_pt