Re: Guile-gnome



Tom Tromey wrote:
> 
> >> The problem is that many Gnome widgets use capabilities that can't
> >> be expressed in the .defs file.  For instance neither arrays of
> >> strings nor GLists can be handled.
> 
> Quartic> Would it be possible to have the guile-gnome bindings
> Quartic> abstract these things into Scheme lists and vectors?  That
> Quartic> would seem to me like a convenient way to handle things.
> 
> Yeah, that's a totally reasonable approach.
> 
> Basically, support for this requires 2 things:
> 
> 1. Syntax in gtk.defs, e.g.:
> 
>         (define-object GnomeMessagebox (GtkWidget)
>            ((list GtkWidget) buttons)
>            (bool modal))
> 
> 2. Code in gen-typeinfo to generate code that does appropriate
> conversions.  In the above case, that would mean functions to convert
> Scheme lists to GLists and back again (with appropriate type checking
> on list elements, etc).

The reason why guile-gtk supports at this point only simple types, is
that they can handled as values. gtk functions with glists use
references. If you start moving references from C to Scheme and the
other way round, you will get some nasty gc problems. (see the current
refcounting changes)

Some gtk functions use *int as a return value. As a matter of principle
this is a through reference. A variable goes in, can be changed and
comes out. The reason why gtk uses a through reference ist, that C does
not have multiple return values.

If you limit the gtk interface description to in and out values, you can
easily create Scheme mappings, but if you think of the the gtk arguments
as of references, you will probably get some difficult problems.

Nevertheless gtk.defs should contain a adequate description of the gtk
interface independent of what a special backend can handle. Originally
gtk.defs was defined by Marius with Guile (Scheme) in mind. So gtk.defs
contains only things which Scheme can handle. This is a matter of
change.

It is likely that gtk.defs will look like this in the future:

(define-func gtk_button_box_set_child_size	 
  none                     ; return value
  ((GtkButtonBox widget)   ; in values
   (int min_width) 
   (int min_height))
  ())                      ; out values

(define-func gtk_button_box_get_child_size	 
  none                     ; return value
  ((GtkButtonBox widget))  ; in values
  ((int min_width) 
   (int min_height)))      ; out values

The C and Scheme backendend will create for the set function nearly the
same, but the get function will be quite different. The C backend will
create a int reference and the Scheme backend will create a function
with a chunk, that gets the return values as input arguments.

> One interesting idea was that gtk.defs could be used to generate
> bindings for many languages, not just Scheme.  This still seems like a
> good plan to me.

Yes. gen-typeinfo will become build-gtk-bindings, which has a target
option.

-- 
http://www.ping.de/sites/aibon/



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