This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hello Everybody, Last week I ask whether anybody (except me) used the FFCALL library. It seems that I may be the only one, but there was a little interest in the guile bindings I am using. So I took that as an excuse to learn autoconf and friends and here is the result. <http://superk.physics.sunysb.edu/~mcgrew/guile/foreign-1.0.tar.gz> This provides essentially the same functionality as libffi, but it's different (probably not better). It uses the ffcall library by B. Haible, so you'll need to download that to play. I've put a copy in the same directory as foreign. <http://superk.physics.sunysb.edu/~mcgrew/guile/ffcall-1.3.1.tar.gz> Cheers, Clark ******************************************************************** GUILE-FOREIGN This packages adds a few modules to allow guile to use dynamically linked foreign functions. To use this extension, you must have a guile interpreter that has been compiled with dynamic loading enabled. Virtually all of the functionality comes from the excellent ffcall library by Bruno Haible. Please download it from <ftp://ftp.santafe.edu/pub/gnu/ffcall-1.3.1.tar.gz> and check out the web page at <http://clisp.cons.org/~haible/packages-ffcall.html>. WHY NOT G-WRAP: G-Wrap is a great way to call functions in other librarys. If you aren't using it already, then please check it out. However, I often find that I want to call one routine out of a library once, or that the library is huge and I don't want to hack a general interface (think X and Xt). In these cases, I find it easier to just call the C routines directly. I also run into situations where I want to pass a callback written in scheme to some C function. This is a relatively difficult problem to solve generally, but FFCALL solves it. HIGHLIGHTS: It calls foreign functions. The (foreign function) module provides a simple way to make foreign functions look and feel like normal scheme procedures. It references pointers: The (foreign pointer) module provides an interface to allocated memory structures. This lets guile deal with struct's and pointer to struct's that have been allocated by C functions. Together with the (foreign function) module this lets you handle any mess that C might throw at you. It even lets you create allocated structures so that you can call C routines. It turns scheme procedures into C functions: The "function" procedure takes a lambda and returns a pointer to a function that can be passed to a C routine [using (foreign function) of course]. The resulting function can be called in C just like a normal C routine. NEAT TRICKS: A simple interface to the Xt library has been provided as part of this packages. I've already used it to write relatively complicated X programs for guile and have yet to find something I can't do directly from scheme. I think it is possible to implement a full Xt widget in scheme, but I haven't tried. A very simple example has been included in "xtest.scm" as well as a more complicated "stest.scm". Also look at "fftest.scm" for a simple test of the library. THANKS: This is made possible by Bruno Haible's ffcall package. He did all of the hard work, I just hacked it together for guile.