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

Clark foo.Clark at gmail.com
Mon Jul 4 05:46:11 CEST 2005

On Thu, Jun 30, 2005 at 02:17:02PM -0700, Ralf W. Grosse-Kunstleve wrote:
> 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
Yes. But we can still emulate what SWIG does to make a C++ Object be a
Python Object, and then return 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 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig

More information about the Cplusplus-sig mailing list