Skip to content
/ gir2cl Public

This is a library for generating a Common-Lisp foreign function interface (FFI) from GObject Introspection XML files (GIR files).

License

Notifications You must be signed in to change notification settings

kat-co/gir2cl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:test-system :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.

About

This is a library for generating a Common-Lisp foreign function interface (FFI) from GObject Introspection XML files (GIR files).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published