Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

potyl (8582)

potyl
  (email not shown publicly)
Jabber: emmanuel.rodriguez@gmail.com

Journal of potyl (8582)

Monday May 18, 2009
03:31 PM

Glib closures

[ #38997 ]

Libchamplain had a major release a few weeks ago and it introduced a MapSourceFactory which allows map sources to be registered, instantiated and easily swapped. This is a great addition as all map sources are now created in the same way. Displaying a combo box with all maps available is truly simple now.

The factory also allows user code to provide their own map source and to register it with libchamplain. Which means that once the factory will be properly binded in Perl it would be possible to implement a MapSource in pure Perl!

I was anxious to get this new feature but it came at a price: the bindings have to support the passing of a Perl sub (CODEREF) and to execute it when a map source is implemented in Perl. While, Glib and Gtk2 are overloaded with CODEREFS (after all the signal systems is implemented through callbacks), I had no idea how to implement this. To make things worse the callback for creating a new MapSource had no arguments which made the task impossible.

I finally had the time to refactor libchamplain and to modify the C callback signature in order to accept an extra parameter. Exactly as all Glib and Gtk2 callbacks do. This made it possible for me to reuse Glib's mechanism for binding callbacks. Thus, now it possible to create a MapSource in Perl!

This was the last bit that was missing in the Perl bindings. Now Champlain.pm has a total coverage of all functions and variables defined in libchamplain. The code needs still to be cleaned up a little bit and some pieces need to be refactored. But at least and at last I have a working version.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.