As a simple example, a file containing
(in-package "POSIX") (wrap:c-lines "#include <unistd.h>") (wrap:c-function getuid "getuid" () :integer) (wrap:c-function getlogin "getlogin" () :string)defines an interface to the POSIX getuid and getgid functions. The wrapper generator produces a C and Lisp file. After compiling the C file into a shared library and loading the Lisp file, the functions can be used:
> (posix:getuid) 100 > (posix:getlogin) "luke"
As a more complex example, the code
(wrap:c-lines "#include <pwd.h>")
(wrap:c-pointer (:struct "passwd")
(:get pw-name "pw_name" :string)
(:get pw-uid "pw_uid" :integer)
(:get pw-gid "pw_gid" :integer)
(:get pw-dir "pw_dir" :string)
(:get pw-shell "pw_shell" :string))
specifies an interface to the structure returned by the getpwnam
function. Similar expressions would be used to define interfaces to
C++ objects.
This system is not yet complete; in particular it does not yet include a mechanism for specifying callback functions, automatic makefile/project creation, or FORTRAN and C++ wrapping.