I have two classes, the first called “Radish” and the second called “RadishCont”.
All the code is written in C++ and need to be used in python.
Radish have been exposed to python using SWIG; RadishCont, instead, have been exposed using boost::python.
I need to add a method into the class RadishCont that has this syntax:
Radish* get_radish()
{
return &radish;
}
Where “radish” is a Radish instance contained in RadishCont.
When I execute the python code I receive this exception:
TypeError: No Python class registered for C++ class Radish
So, my question is: how can I make this method work in python without rewriting RadishCont using SWIG ?
At the end, I have done it.
I have created a class instance in my boost python module like this:
I have created a converter function like this:
Where PySwigObject is a struct like this:
Last, I have registered my converter:
This perfectly works, I can get objects from SWIG and pass it to boost::python. The inverse process is still unsolved but is enough for me.
This is the guide I have used to find the solution:
http://wiki.python.org/moin/boost.python/HowTo#SWIG_exposed_C.2B-.2B-_object_from_Python