[C++-sig] In a C++ extension, how to use a C++ class exported in another extension

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Thu Jun 30 23:17:02 CEST 2005


Thanks for posting this. It is very interesting!

David, how difficult would it be to provide something like

  boost::python::arg_from_swig_object<Foo>();

so that we could wrap functions taking SWIG-wrapped arguments directly?
I guess there is no easy way to construct SWIG-wrapped return values without a
lot of support from SWIG, but automatically extracting the pointer to turn it
into a T*, T&, const T*, const T& argument seems like something that may not be
too hard... true?

Looking some more, isn't this almost it?

  http://www.boost.org/libs/python/doc/v2/lvalue_from_pytype.html

But we want to do it without having the equivalent of noddy_NoddyType, just
knowing that ((PySwigObject*)obj.ptr())->ptr gives us the T*.

Cheers,
        Ralf

--- Clark <foo.Clark at gmail.com> wrote:

> It takes much time of me to solve this problem.
> 
> The answer is: 
> A class member named "this" is added to every python class wrapped by
> SWIG. The "this" is a "PySwigObject", which has a member points to 
> the C++ 'this' pointer.


		
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 



More information about the Cplusplus-sig mailing list