[C++-sig] Type conversion problem -- simplified

Randall Hopper viznut at charter.net
Sun Nov 5 16:44:24 CET 2006


David Abrahams:
 |Randall Hopper <viznut at charter.net> writes:
 |> The puzzling thing about all this is, when I create an osg.Vec3Array inside
 |> of Python, then I can call methods (such as __getitem__, set, etc.) on that
 |> Vec3Array from inside Python with no problem.
 |>
 |> But if I obtain a reference to a Vec3Array (e.g. returned from that
 |> Geometry::getVertexArray() API above) which was generated internal to
 |> OpenSceneGraph), then I get the error message I mentioned previously.
 |
 |When you pass both kinds of Python Vec3Array object to type(), do you
 |see the same thing in both cases?

Yes:

<class 'PyOSG.osg.Vec3Array'>

 |> This makes me thing something isn't being correctly done inside that
 |> "manage_osg_object" return policy, but I have no clue what that is
 |> yet.
 |
 |What is the return type of get_pointer(x) where x is an
 |osg::ref_ptr<T>?

(T *).  Here's the relevent code:

   namespace osg {

   template<class T> inline T * get_pointer(osg::ref_ptr<T> const & p)
   {
       return const_cast<T *>(p.get());
   }

   }


By the way, all efforts so far to trim down the code have been too sweeping
to keep the problem.  So I'm still binary searching to get even get a small
test program.

I wish I had some understanding of what the problem is so I could focus my
efforts.  Could you give me your perception of what it is?

Thanks,

Randall



More information about the Cplusplus-sig mailing list