Skip to content
This is a library for generating a Common-Lisp foreign function interface (FFI) from GObject Introspection XML files (GIR files).
Common Lisp
Branch: master
Clone or download
kat-co Merge pull request #3 from kat-co/fix-2
Blacklist -> Whitelist for Determining Whether to Processing Nodes
Latest commit 93ebf8d Feb 4, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Blacklist -> Whitelist for Determining Whether to Processing Nodes Jan 25, 2020
tests
.gitignore
LICENSE Initial commit Jan 6, 2020
README.org
gir2cl.asd

README.org

About

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:

  1. The code has only been tested on Linux with SBCL. It is intended to be tested with other Lisp implementations.
  2. The generated code has not been tested very broadly, nor deeply.
  3. There are not very many unit tests written yet.
  4. Only classes and methods are currently supported.

Installation

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.

How to Work with the Sourcecode

From a REPL run:

(asdf:operate :test-op :gir2cl)

How to Generate Code

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"))

How to Utilize the Generated Code

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.

FAQ

Is the generated source code also covered by the LGPL v3?

No. You are free to license the generated code as you see fit.

You can’t perform that action at this time.