This is a library for generating a Common-Lisp foreign function interface (FFI) from GObject Introspection XML files (GIR files).
Please note that this does not generate the actual FFI, rather it generates bindings in terms of the wonderful cl-gobject-introspection project. The Common Lisp wrapper types which are generated are useful for working with a GIR library’s object hierarchy in a way which is more natural to Common Lisp.
There are also some caveats:
- The code has only been tested on Linux with SBCL. It is intended to be tested with other Lisp implementations.
- The generated code has not been tested very broadly, nor deeply.
- There are not very many unit tests written yet.
- Only classes and methods are currently supported.
I plan to get this into quicklisp. For now, please clone the directory, make ASDF aware of its location, and run (asdf:load-system :gir2cl)
. libgobject
must be on your CFFI
path.
From a REPL run:
(asdf:test-system :gir2cl)
This library is intended to be used through a REPL.
(with-open-file (stream #P"./gtk.lisp" :direction :output :if-exists :supersede)
(gir2cl:generate "#:gtk-low-level" "Gtk" stream "/usr/share/gir-1.0/Gtk-3.0.gir"))
gir2cl
pretty closely follows the GIR declarations and generates classes, methods, and functions which make the classes and take in the appropriate arguments to do so. All classes inherit from a base-class, gir-object
.
Utilizing the methods is a little cumbersome at the moment as it expects GIR types, and not the Common Lisp types which have been generated. For that reason, you will probably be doing a lot of this:
(let ((my-obj (my-gir-lib:make-my-object)))
(my-gir-lib:do-the-thing (my-gir-lib:native-pointer my-obj)))
I would like to make this less cumbersome in the future.
No. You are free to license the generated code as you see fit.