Re: Marshallers, _interp, and the Meaning of Life




Jay Bloodworth <jay@pathways.sde.state.sc.us> writes:

> On Tue, 10 Feb 1998, Tim Janik wrote:
> 
> [good explanation of marshalling snipped]
> 
> Thanks, that was very helpful.  One more question:
> 
> > 
> > which without marshalling would have looked like
> > static void
> > gtk_real_window_move_resize (GtkObject      *object,
> >                              gpointer        func_data,
> >                              GtkArg         *args)
> > {
> >   gint *x;
> >   gint *y;
> >   gint width;
> >   gint height;
> >   gint *return_val;
> >   
> >   return_val = GTK_RETLOC_BOOL (args[4]);
> >   x = GTK_VALUE_POINTER (args[0]);
> >   y = GTK_VALUE_POINTER (args[1]);
> >   width = GTK_VALUE_INT (args[2]);
> >   height = GTK_VALUE_INT (args[3]);
> >   
> >   [...]
> >   
> >   *return_val = something_that_came_out_of_the_function;
> > }
> > 
> 
> So marshalling basically moves the code that references, casts, and names
> arguments in the GtkArg array into a separate function.  I see how this is
> a big win in terms of program neatness, especially if you aren't concerned
> with the situations that require marshallers.  Are there any other
> advantages to using a marshalling system?

I think the point which was being made was a bit more dramatic -
the marshalling system allows your callback functions to look
just like normal C functions.

Marshalling means that a C-like call:

 gtk_signal_emit_by_name (widget, "button_press_event", &event);

can go through a sophisticated dispatching system (be dispatched
multiple places, go to default handlers before or after the
user defined handlers, etc), and then have the final callbacks
be C-like again:

  gint button_press_handler (GtkWidget *widget, GdkEvent *event,
                             gpointer data);

Also, the marshalling system allows interpreted language bindings
to hook in above the level of the C marshaller and provide their
own translation of the GtkArg into the target language.

Regards,
                                        Owen



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