[C++-sig] call_method trouble?

David Abrahams dave at boost-consulting.com
Mon Mar 10 17:46:45 CET 2003


Dirk,

I think the fact that you are posting in HTML (I'm guessing) is
causing your code to be formatted badly in the mail messages.  Please
try posting in Plaintext.

It looks to me like FXObjectWrap::python_handle should be calling
FXObject::handle rather than the unqualified handle, because it will
cause an infinite recursion otherwise when invoked via the Python
onMessage callback.  Also, you should probably be using the "virtual
function with default implementation" wrapping formula described at
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/python/doc/tutorial/doc/virtual_functions_with_default_implementations.html.

One possible explanation for the problem is that type information is
lost when converting your FXObject* to a Python object in this line:

   long res = call_method<long>(o, method_name, boost::python::ptr(sender), sel);

Are you using the latest CVS state or the 1.30.0 beta?  These are way
ahead of the 1.29.0 release in handling polymorphic classes.


"Dirk Ulbricht" <fxdirk at insanesoftware.de> writes:

> Hello,
>
>  
>
> first a big thank you to everone working on boost.python, this library
> rocks! However, I have come across a problem I just can not solve. I
> apologize for the length of the post, but in order to demonstrate the
> problem I had to include this code. This is the class I try to wrap:
>
>  
>
> class FXObject
>
>       {
>
> public:
>
>       virtual long handle(FXObject* sender, FXSelector sel, void* ptr)
>
>             {
>
>             }
>
> };

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list