Re: libbonobo closureization



Hi Gergo,

On Mon, 30 Jul 2001, ERDI Gergo wrote:
> Is there a remote chance of this getting accepted? If yes, I am
> willing to modify the other callbacks in libbonobo to use GClosures as
> well. The importance of this is that if we don't do this before the
> API freeze, language binding authors can get in an awkward situation.
  
        Yes - this is really important.
  
        _But_ before you commit your patch - it needs alteration. We don't
want to foist the horrors of raw GClosure usage on the unsuspecting
public. So I would prefer to leave eg.
  
bonobo_event_source_client_add_listener (MyCbFn fn,
                                         gpointer user_data)
{
        GClosure *c = g_cclosure_new (fn, user_data, NULL);
  
        bonobo_event_source_client_add_listener_gclosure (c);
}
  
        etc. So that while we provide the GClosure option - which as you
point out is vital, we don't screw ourselves with a serious compatibility
nightmare.
        
> +     g_value_init (&arguments[0], BONOBO_GENERIC_FACTORY_TYPE);
> +     g_value_set_object (&arguments[0], factory); 
> +
> +     g_value_init (&arguments[1], G_TYPE_STRING);
> +     g_value_set_string (&arguments[1], oaf_iid);
> +
> +     g_value_init (&ret_val, BONOBO_OBJECT_TYPE);
> +       
> +     g_closure_invoke (factory->priv->factory_cb,
> +                       &ret_val,
> +                       2,
> +                       arguments,
> +                       NULL);

        
        Ok, I wrote a helper function here called
  
        bonobo_closure_invoke [ in bonobo-types.h ], it should
considerably simplify the process of invoking closures. You only need to
setup and init the return value; so here you would do something like:
  
static BonoboObject *
bonobo_generic_factory_new_generic (BonoboGenericFactory *factory,
                                    const char           *oaf_iid)
{
        GValue retval;
 
        g_return_val_if_fail (factory != NULL, NULL);
        g_return_val_if_fail (BONOBO_IS_GENERIC_FACTORY (factory), NULL);

        g_value_init (&retval, BONOBO_OBJECT_TYPE);

        bonobo_closure_invoke (
                factory->priv->create, &retval,
                BONOBO_GENERIC_FACTORY_TYPE, factory,
                G_TYPE_STRING, oaf_iid,
                0);

        return g_value_get_object (&retval);
}
  
        Or somesuch.
  
        Apart from that - this patch looks _extremely_ good - I'm so
pleased you've been busy addressing the problem that was most worrying me,
and as you can see - I started addressing it with bonobo_closure_invoke on
Saturday evening.

        Thanks Dude, catch you on IRC hopefully,
 
        Regards,
  
                Michael.

-- 
 mmeeks gnu org  <><, Pseudo Engineer, itinerant idiot





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