[gtk-list] Re: scheme/gtk

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_


GtkFrame *
	gchar *	label
	RETVAL = (GtkFrame *)gtk_frame_new(label);

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.


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]