Re: using c-methods for callbacks?

Greg Ewing <[email protected]> Sun, 31 May 2009 14:21:45 +1200
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
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