[Pyrex] using c-methods for callbacks?

Greg Ewing greg.ewing at canterbury.ac.nz
Sun May 31 04:21:45 CEST 2009


horace wrote:

> it would be great if i could use c-methods for callbacks but i always 
> get a crash if i access self. am i doing something wrong or doesn't self 
> get assigned correctly if the method gets called from a c-library?

You can't use C methods that way, because there's no such
thing as a bound C method. Pyrex won't even let you try
to create one:

cdef class C:
   cdef void m(self):
     pass

cdef int f(C c):
   cdef void *g
   g = <void *>c.m

% pyrexc foo.pyx
/Users/greg/foo/foo.pyx:7:14: C method can only be called

-- 
Greg



More information about the Pyrex mailing list