On Sat, 2004-03-06 at 21:31, Tom Hargreaves wrote:
I don't know if anyone's tried using Inline::C with gtk2-perl; I don't recall seeing it mentioned here.
my gut reaction is a loud hiss, followed by a growl. but then i remember that Inline::C is really handy when all you need is one piddly little C function, and i come to my senses.
One thing I'm unsure about is how to portably locate gperl.h: would searching @INC be wise? Currently I've just hardcoded the path...
which, of course, is not where it is on my machine, so i had to hack at it just to run it, and found a few interesting things... you don't really ever want to use gperl_get_object() by itself; each extension's main header includes automagically generated wrapper macros which call it for you, and those macros are used by the generated typemaps. so, instead of da = gperl_get_object_check (area, GTK_TYPE_WIDGET); you want to do da = SvGtkWidget (area); but even better than that would be to have Inline::C apply the typemap for you (as is done in the attached patch)! this, of course, means you need to find gtk2perl.h and the Gtk2 typemaps, so we're back to your problem about finding a header. ExtUtils::Depends is gtk2-perl's solution to this. i used a new depends object to find and collate for me the INC, LIBS, and TYPEMAPS that Inline::C needs to compile all this stuff. there's a problem, though; Inline::C's docs say that the TYPEMAPS parameter takes whatever MakeMaker takes for TYPEMAPS, but this is a dirty filthy lie -- MakeMaker takes a filename or an array of filenames, but Inline::C takes only one filename. so, i had to do something *really* ugly --- compile all the typemaps from Gtk2 and Glib (there are at least three files) into one temporary typemap file and pass *that* to Inline::C. you'll want to fix up this code to make the ExtUtils::Depends stuff run only when Inline::C needs to compile, but otherwise, the patch attached should make your previously posted version run "anywhere". i think this TYPEMAPS thing is a bug in Inline::C, but until that gets fixed, we may want to consider whether the Evil Magick required to get ExtUtils::Depends to work with Inline::C and all that should be wrapped up into ExtUtils::Depends. what think you?
Finally, a huge thanks to everyone who helped make gtk programming this much fun!
hey, thanks for writing a cool program! meander is spiffy. -- muppet <scott at asofyet dot org>
Attachment:
meander-depends.diff
Description: Text document