girtobac  0.4
Create FB Headers from GObject Introspection *.gir files
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Introduction

Table of Contents

This project is about a new header generator for the FreeBasic (FB) programming language. It creates FB headers by scanning *.gir files.

*.gir files are generated by the GObject-Introspection (GI) technology. GNOME libraries based on GLib/GObject use these technology to support polyglot application development. This means a library developed in C can be also used in higher level programming languages like JavaScript, Python, Vala or others. The GI system helps to auto-generate bindings for these high-level programming languages.

girtobac is the first attempt to connect FreeBasic (FB) to these supports. It reads the GI *.gir files (generated during compilation of the C library) and transforms their context to FB headers. Some manual control is needed to adapt the output. This is done by a configuration file (one for each *.gir file). These configuration files can be re-used for up-dated *.gir files further on.

How does this work?

girtobac is a command line tool, being shipped as FB source code. The code needs to get compiled first. The executable expects one parameter, the name of the *.gir file (maybe prepended by its relative or absolute path). It loads this file and additionally a configuration file with the same base-name and the suffix .GirToBac (if present in the current folder). Then the context of the *.gir file gets translated to FB source by respecting the rules in the configuration file. The result gets written to the current folder as an FB header file named after the basename and with suffix .bi (overwriting existent files). In best case the header contains all information to use the library in FB source code.

The headers are designed to be stored in one directory, one header for each library (= dll binary). Each header loads the dependencies its library is based on, so the user need not care about chaining-up. Just load the highest level header and your source contains all dependencies (the binaries must have been installed before).

To generate an FB header the *.gir files gets scanned several times:

  1. First, some constants get #DEFINEd and TYPE aliases and ENUM blocks gets translated.
  2. In the second pass UNIONs, TYPEs and callback prototypes are done. Some of them are based on others and fbc need to read them in the logical order (use the control file to re-order).
  3. The last step is to translate static SUBs/FUNCTIONs declarations.