[32] in The GTK GIMP ToolKit mailing list archive
[gtk-list] Re: scheme/gtk
daemon@ATHENA.MIT.EDU (Owen Taylor)
Fri May 2 17:52:20 1997
To: gtk-list@redhat.com
From: Owen Taylor <owt1@cornell.edu>
Date: 02 May 1997 17:50:31 -0400
In-Reply-To: Peter Mattis's message of Thu, 01 May 1997 23:57:40 -0700
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com
Peter Mattis <petm@scam.XCF.Berkeley.EDU> writes:
> Owen, I'm curious, how did you actually create all the bindings
> between C and perl. When I originally started doing the scheme/gtk
> interface I created the glue between them by hand. Way too much
> work. I gave up. I came back to the problem a few months later and
> disovered lcc (a really small ansi compiler), wrote a special purpose
> backend which searches for gtk/gdk functions and constants and
> automatically generated 99% of the glue between scheme and
> C. (Callbacks have to be handled specially). I'm aware that perl has
> some sort of interface generator (perlxs), but I've never used it and
> am curious to know if you used it and if so, how well it worked.
The XS tools do simplifiy writing Perl interfaces quite a bit -
you specify conversions between C types and Perl variables in
a typemap file (a default one is provided for the basic types),
then you specify the functions in an XS file that looks like:
MODULE = Gtk PACKAGE = Gtk::Frame PREFIX = gtk_frame_
guint
gtk_frame_get_type()
GtkFrame *
gtk_frame_new(label)
gchar * label
CODE:
RETVAL = (GtkFrame *)gtk_frame_new(label);
OUTPUT:
RETVAL
But by itself it still would have been pretty tedious to write
the XS file, so I used a combination of some standard Perl modules
and some Perl programs of my own to do a heuristic parse of the
the gtk header files and spit out the .xs file and some associated
C glue. (By "heuristic", I mean that it works for the gtk header
files, but would fail horrible on lots of legal C.) The system
is a bit messy, but was pretty easy to get working.
For a couple dozen functions where I wanted to change the interface
to something more perlish (e.g., multiple return values), I wrote
the XS file by hand.
Regards,
Owen
--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null