chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] (new) gtk+ egg using swig


From: felix winkelmann
Subject: Re: [Chicken-users] (new) gtk+ egg using swig
Date: Thu, 1 Sep 2005 08:41:51 +0200

On 8/31/05, Alejandro Forero Cuervo <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]