Help with turning procs into C function pointers


#1

Hi Guys,

I’ve been looking at the way the signal dispatcher works in
rbgobj_signal.c to try to figure out how to call an exteral C function
which takes a callback function pointer. I have to say that being
unfamiliar with extending Ruby in C (except from getting luck with some
fairly blind cloning of existing bindings), being unfamiliar with the
API used within the ruby-gnome2 bindings and really not being all that
familiar with using GTK+ from C, I’m having some trouble figuring out
exactly what I need to do.

Given the following

typedf void (*callback)(char *p1, int *p2);
void my_function(int x, callback fn);

How would I implement the wrapper C function for the ruby class, e.g.

class Foo
def my_function(x, &block)
end
end

but in C?

I know this isn’t specifically about ruby-gnome2, but I’m experimenting
with a set of bindings for GtkHTML3 since I’m not having much luck with
GtkHTML2. Since I’m trying to make it consistent with what’s already
part of the official bindings in case anyone else wants it, I figured
this was the best place to ask.

Thanks in advance,

ast

Andrew S. Townley removed_email_address@domain.invalid
http://atownley.org


#2

Hi,

In 1224062496.7270.77.camel@linna
“[ruby-gnome2-devel-en] Help with turning procs into C function
pointers” on Wed, 15 Oct 2008 09:21:36 +0000,
“Andrew S. Townley” removed_email_address@domain.invalid wrote:

end

but in C?

callback needs to accept extra void * user_data
argument. The argument should be used to pass Ruby object.

Thanks,

kou