guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proof of concept dynamic FFI


From: Kjetil S. Matheussen
Subject: Proof of concept dynamic FFI
Date: Thu, 19 Jul 2007 18:58:42 +0200 (CEST)



Jon Wilson:

Hi,
I've written a bit of code that lets you call any function from a
dynamically loaded shared lib with any args.  Well, actually, since it
is just a proof of concept, it only lets you call functions that take
zero or one args.  The arg (if there is one) must be of type int.  The
return type can be either void or int.

If you want to play, you can get the code by
bzr branch http://bzr.wilsonjc.us/foreign/
or by just grabbing the files from that URL manually.  The README
contains brief instructions on how to try it out.

If I'm just reinventing the wheel, or if you can think of a better way
to do it, or if you just think I look funny, let me know.
Regards,
Jon Wilson



With guile, I usually prefer writing c-code using s-expressions:


(load "eval-c.scm")

(eval-c ""
        (public
         (<void> hello-world (lambda ()
                               (printf (string "hello world\\n"))))))

(hello-world)
=> hello-world


(eval-c ""
        (public
         (<int> add-ints (lambda ((<int> a)(<int> b))
                           (return (+ a b))))))
(add-ints 2 3)
=> 5


etc.


http://snd.cvs.sourceforge.net/snd/cvs-snd/eval-c.scm





reply via email to

[Prev in Thread] Current Thread [Next in Thread]