Re: Exporting the Gtk+ object system to interpreters [was:no_marshall signals and GtkTypeInfo]



On 7 Dec 1998, Marius Vollmer wrote:

> I'm currently hacking (rather unfocused) on exporting the Gtk+ object
> system to Guile Scheme.  For that I need a few hooks into the Gtk+
> signal and type system.  I thought that the stuff that I committed is
> innocent enough to just go in without much justification.  Obviously I
> was wrong and I want to apologize for not following the `Dienstweg' ;-)

i've added a gtk_type_query() interface (similar to gtk_signal_query)
as you may have noticed, please tell me if that fullfills your needs.

> One of the problems are the class functions, I think.  With "class
> function" I'm referring to the functions that are directly pointed to
> from the class structures of a type, like gtk_button_draw.  I want to
> be able to use interpreted functions for these class functions, altho
> I'm not sure if I need them.  Therefore, I want to add this function
> to Gtk+:
> 
>   void gtk_signal_set_class_function_full (GtkType            type,
> 	    				   const gchar       *signal,
> 		    			   GtkSignalFunc      func,
> 					   GtkCallbackMarshal marshal,
> 					   gpointer           data,
> 					   GtkDestroyNotify   destroy_func);
> 
> It would do some magic so that one is able to use the established
> "full" interface for setting class functions, including ones with a
> custom marshaller and destroy notification.  This can be done with an
> overhead of two flag tests per signal invocation when the above
> function has not been called on a type (which will be the ususal case)
> and two additional words in GtkObjectClass.
> 
> The above function will cover replacing the default handler for
> existing signals.  It should also be possible to add new signals to
> new types.
> 
> The problem with that is to provide default marshal functions for
> arbitrary new signals.  So I settled for allowing for signals without
> default marshallers.  You can only connect handlers to such signals
> that have their own custom marshaller.

hm, there's actually a bunch of things that needs to be adressed to
get the signaling behaviour you require.
1) you need to create signals that don't provide normal marshallers
   at all (i.e. the default handlers and possibly connected handlers
   will always be invoked with unmarshalled parameters: guint n_params,
   GtkArg *params).
2) you need a mechanism to specify a default-handler with gpointer *data
   arg that is not retrived via the normal class offset.
3) you need a mechanism to eventually chain the default handler of the
   parent class (e.g. if you create a new container type in scheme, you'd
   probably want to chain the GtkContainer::add handler of the parent
   class from within your scheme-default-handler).

so if i understood your (and keneth) needs correctly, some thing like
the following should be sufficient:

guint gtk_object_class_unmarshalled_signal_newv  (GtkObjectClass     *klass,
                                                  const gchar        *name,
                                                  GtkSignalRunType    signal_flags,
                                                  GtkSignalMarshaller default_handler,
                                                  gpointer            default_data,
                                                  GtkType             return_val,
                                                  guint               nparams,
                                                  GtkType            *params);
void gtk_object_class_chain_parent_handler (GtkObjectClass *klass,
                                            guint           signal_id,
                                            GtkArg         *args);

the default handler for such a signal would then be passed as default_handler
to the first function, and it's signature would be:
void interp_default_handler (GtkObject      *object,
			     guint           signal_id,
			     guint           n_params,
                             GtkArg         *params,
                             gpointer        default_data);
(i'm passing in the signal_id, because i assume you'd most likely want to use
the same function to marshall the distinct default handlers for different kinds
of newly created interpreter signals).
from interp_default_handler(), the parent classes default handler can then
be chained with
gtk_object_class_chain_parent_handler (object->klass, signal_id, args);
if any C function connects to such a signal (which would be flagged as
GTK_RUN_UNMARSHALLED) the handlers prototype would be the same as for
interp_default_handler().

> 
> - Marius
> 

---
ciaoTJ



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