i am wrapping an abstract class "Actor" which is to be implemented partially
in Python, using a wrapper class that looks like this:

class PyActor : public Actor, public wrapper<Actor> {
public:
  ....
};

the boost.python export code looks like this:

class_<PyActor, boost::noncopyable>("Actor");

this would be all good and well, until I decided to pass back Actor pointers
from methods e.g. like Actor::get_parent(), which have to resolve back to
original python objects, for which the FAQ suggests using shared_ptr, if
altering the underlying code was possible - which it is.

so there is now a method in Actor declared like this:

// assumed: typedef boost::shared_ptr<Actor> ActorPtr;

ActorPtr Actor::get_parent();

unfortunately calling that method gives me a new wrapped Actor python object
- not exactly what the FAQ promised. but I read that the shared_ptr<> has to
be declared as the object holder, like this:

class_<PyActor, ActorPtr, boost::noncopyable("Actor");

which I did, but that gives me a compiler error if Actor is abstract, and if
I declare it non-abstract, calls to wrapping PyActor methods fail in Python.
I guess that this approach does not work with wrapper classes, or the syntax
is different.

how do I have to do it? I searched through the mailing list but found
nothing viable so far.

thanks in advance!
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to