On 8/31/05, Alejandro Forero Cuervo <[EMAIL PROTECTED]> wrote:
>
> It seems to work but we still need to resolve some issues.
>
> We are currently doing this in our interface file:
>
> %{
> static void
> EGG_signal_handle ( gpointer *obj, gpointer closure_root )
> {
> C_callback(CHICKEN_gc_root_ref(closure_root), 0);
> }
> %}
>
> %inline %{
> gulong
> EGG_g_signal_connect (gpointer obj, const gchar *type, C_word closure)
> {
> void *closure_root = CHICKEN_new_gc_root();
> CHICKEN_gc_root_set(closure_root, closure);
> return g_signal_connect(G_OBJECT(obj), type,
> G_CALLBACK(EGG_signal_handle), closure_root);
> }
> %}
>
> Ignore, for the moment, the memory leak there. When the Scheme
> programmer calls "(gtk-main)", a wrapper for gtk+'s "gtk_main", we can
> expect "EGG_signal_handle" to get called. Is it safe to use
> "C_callback" there? If not, is there a way to tag "gtk_main" such
> that calls to (gtk-main) will call it safely (just like
> foreign-callback-lambda does)?
>
Currently there is no way to tell this to SWIG, AFAIK. What you can
do is to provide your own gtk-main, that calls the real one:
%insert(chicken) %{
(define gtk-main
(foreign-safe-lambda* void ()
"gtk_main();") )
%}
(barely tested, but should work)
cheers,
felix
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users