In the past, Cython accepted such code. Unfortunately, at some point
this functionality was lost. However, you can add a forward
declaration and a ctypedef like this:

cdef class LstFileReader_FAST # forward declaration

ctypedef tuple read_fn_t(LstFileReader_FAST) # ctypedef for function type

cdef class LstFileReader_FAST:
   cdef read_fn_t *do_read_ev # note do_read_ev is a pointer to read_fn_t !!!



On Mon, Apr 20, 2009 at 12:17 PM, Jean-Francois Moulin
<[email protected]> wrote:
> Hi
>
> I am struggling with a function pointer problem:
>
> cdef class LstFileReader_FAST:
>    cdef tuple (*do_read_ev)(LstFileReader_FAST)
>
>     def __init__(self,fname):
>
>        self.fname = fname
>        self.goto_start()
>        self.do_read_ev = self._next_ev
> .....
>
> results in a compilation error:
>
> Cannot assign type 'tuple (LstFileReader_FAST, int
> __pyx_skip_dispatch)' to 'tuple (*)(LstFileReader_FAST)'
>
> I found no clear explanation for this __pyx_skip_dispatch... and
> somewhere above in my code I have an almostt similar statement which
> works:
>
> cdef int (*locate)(DelayLine, np.ndarray)
> ...
>    def __init__(self):
>               ....
>                self.locate = self.locate_single_terminal
>
>
> Any clue?
> Thanks in advance for helping a beginner!
> JF
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to