Minor GClosure improvement



Here's is a very minor GClosure improvement proposal to simplify the Gtk--
binding, and possibly other bindings. It will have no effect on code that
doesn't use it.

In GTK+, if you emit a signal that has a return value, and there are no
callbacks connected and no default handler, then the return value will not be
set at all.

BUT in Gtk--, there is *always* a default handler in order to link with C++.
So, if there is no default handler we set an ignore_ boolean which is checked
in our replacement marshallers.

These marshallers are identical to the GTK marshallers apart from a couple of
lines. For instance, in Gtk-- 1.2:

void 
gtkmm_marshal_BOOL__POINTER_POINTER_INT_INT (GtkObject * object,
                                           GtkSignalFunc func,
                                           gpointer func_data,
                                           GtkArg * args)
{
  GtkSignal_BOOL__POINTER_POINTER_INT_INT rfunc;
  gboolean *return_val,rc;
  return_val = GTK_RETLOC_BOOL (args[4]);
  rfunc = (GtkSignal_BOOL__POINTER_POINTER_INT_INT) func;
  ignore_=false; //*** HERE
  rc = (*rfunc) (object,
                          GTK_VALUE_POINTER (args[0]),
                          GTK_VALUE_POINTER (args[1]),
                          GTK_VALUE_INT (args[2]),
                          GTK_VALUE_INT (args[3]),
                          func_data);
  if (!ignore_) *return_val=rc; //*** HERE
  ignore_=false; //***AND HERE
}

I propose that we add a gboolean ignore_return_value field to GClosure and add
code like this to the GTK marshallers. This means that Gtk-- marshallers can
be much simpler without copy-pasting code. It will not change GTK+ behaviour,
and nobody will need to care about it if they just ignore that field.

May I do this?

Murray Cumming
murrayc usa net
www.murrayc.com

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1




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