[gtk-list] Re: scheme/gtk
- From: Owen Taylor <owt1 cornell edu>
- To: gtk-list redhat com
- Subject: [gtk-list] Re: scheme/gtk
- Date: 02 May 1997 17:50:31 -0400
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]