Forum: Ruby-Gnome 2 Help with turning procs into C function pointers

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
324ce80d9dbe9417607192038fb880bf?d=identicon&s=25 Andrew S. Townley (Guest)
on 2008-10-15 11:22
(Received via mailing list)
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 <ast@atownley.org>
http://atownley.org
Ee6ffca720cc428d70247dcd7377dd48?d=identicon&s=25 Kouhei Sutou (Guest)
on 2008-10-18 07:39
(Received via mailing list)
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" <ast@atownley.org> 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
This topic is locked and can not be replied to.