On Jul 23, 2009, at 3:39 AM, Richard Clarke wrote:

> Hi,
>
> Can anyone point out where I am going wrong?

Sure. There is no way convert a pointer to a Python object. (Perhaps  
we could support this via http://www.python.org/doc/2.6/c-api/ 
cobject.html , but certainly that'll take a lot of thought).

You need to make Bar into a cdef class for it to have a foo_t*  
member. Also, if a return type is foo*, you need to make it a cdef  
function. I would recommend reading http://docs.cython.org/ .

> // foo.pyx
>
> cdef extern from "foo.h":
>     ctypedef struct foo_t:
>         int fd
>
>     foo_t* init()
>
> class Bar:

 > cdef class Bar:
 >     cdef foo* __foo

>     def __init__(self):
>         self.__foo = self.__open()
>
>     def __open(self):

 >     cdef foo* open(self):

>         cdef foo_t *foo
>         foo = init()
>         return foo
>
>
> Results in the error:
> /test/foo.pyx:14:12: Cannot convert 'foo_t *' to Python object
>
> Cython version 0.9.6.14
>
> Thank you,
> Richard.
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to