Hi,
I am wrapping a large simulator with Cython and at one point in the C++ code I need to create a new Python object that contains
one of the wrapper classes from Cython.
The problem would be solved, if I can define a function, either in C++ or cython which gets a pointer to a cython-wrapped class and returns a python object.
The problem can be illustrated with the Rectangle example from the Cython documentation:
The C++ class Rectangle is wrapped by the Python class PyRectangle.
My Question: How can I write a function (in C/C++ or Cython)
PyObject *to_PyObject(Rectangle *rect) ?
When I try something like
cdef object to_pyobject(Rectangle *arg):
return PyRectangle(arg)
or
def to_pyobject(Rectangle *arg):
Cython complains that it 'rect.pyx:32:27: Cannot convert 'Rectangle *' to Python object'
Any Ideas how to do this?
Thanks
Marc-Oliver