On 10.10.2010 03:47, Jim Bosch wrote:

Pretty much everything you need should automatically work, whether you
use shared_ptr or raw pointers with call policies. If you've invoked
register_ptr_to_python on all the classes you're using,

That's what I couldn't get while reading Boost tutorial (the example
code didn't work either :( ).
Let's say I have three classes:

class A {};
class B : public A {};
class C : public B {};

should I later just put:
register_ptr_to_python< A >();
register_ptr_to_python< B >();
register_ptr_to_python< C >();
?
you'll find that
in Python you'll always get the most-derived class, even if it's
returned as a base class pointer or smart pointer on the C++ side.

Here is the small code snippet:

+v
boost::python::call_method<void>(callback,"addToQueue",c);
-v

where callback is a PyObject* pointer,and 'c' is a pointer to the object.
Whenever I call this instruction, I can see that the 'c' object is being
copied (I just put some cout << "debug" << endl in the definition of the
Copy Constructor), so I assumed that Python code doesn't operate on the
object that was created in C++ module. Instead, it just operates on the
copy.

You shouldn't need any extra compiler flags. Just use Boost.Python the
way described in the tutorial, and throw in some register_ptr_to_python
invocations - that should be all you need.




--
best wishes

Marek Denis

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

Reply via email to