This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Writing a Library with Vala:

Binding to the Library from Other Languages

Vala produces C code and also produces C headers. Binding from C is relatively easy, although the library may make use of a lot of GObject boiler plate code.

For Vala based projects, using either the Vala or Genie syntax, a VAPI can be produced that makes bindings easy.

The Vala compiler can also produce a GObject Introspection Repository (GIR) file. This makes bindings from languages that support GObject Introspection very easy. Often the binding is at runtime so a typelib file also needs to be produced and libgirepository and libffi are used at runtime for the binding.

C

Genie

Go

Haskell

As of January 2017 the Haskell generator from GObject introspection repositories, haskell-gi, is described as complete. The Haskell wiki page on GObject Introspection advises "The Haskell code generator at haskell-gi is now essentially complete: all the information exposed in the bindings should now be available from the autogenerated bindings. This includes ordinary functions, signals, virtual functions, structure fields, object properties, etc."

Javascript

Lua

LGI provides runtime bindings for Lua 5.1+ and LuaJIT2. It uses libgirepository to read typelib files.

There are alternative binding generators: lgob and LuiGI. lgob parses GIR files to generate Lua modules. LuiGI was an experimental dynamic binding generator. LGI should be used instead of LuiGI.

OCaml

Perl

perl-Glib-Object-Introspection creates Perl bindings at runtime from a typelib file.

Python

PyGObject is a Python package providing bindings using GObject introspection.

Ruby

Rust

The gtk-rs project has developed the gir tool to generate Rust bindings from a GIR file.

Vala


2024-10-23 11:37