[C++-sig] passing wrapped c++ objects to boost wrapped function

Roman Yakovenko roman.yakovenko at gmail.com
Fri Jan 5 19:52:02 CET 2007


On 1/5/07, Kim Branson <kim.branson at stanford.edu> wrote:
>
> On Jan 4, 2007, at 3:38 PM, Alex Mohr wrote:
>
> >> The OEMol was not wrapped by me, but a vendor. I have the headers,
> >> and the python bindings appear to be generated by swig.

Small and "not important" detail :-)

> > If that's true, then boost.python cannot "just know" how to get the
> > C++
> > OEMol object out of a swig-generated wrapping Python object.
> >
> > You might be able to teach boost.python how to deal with OEMols by
> > registering your own to_python and from_python conversions for OEMol
> > which use swig to do the work.
> >
>
> is there a good source of documentation/examples on how to do this in
> Boost.
> My knowledge of c++ templates is poor and it looks fairly complex.

Take a look on this example:
http://www.boost.org/libs/python/doc/v2/faq.html#custom_string

You can do something similar.

I think it also possible to extract the reference to OEMol instance
from the PyObject, but you need to know low implementation details of
SWIG. In this case there is also a question of memory management.


-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list