Erstellen der .defs-Dateien.

The .defs files are text files, in a lisp format, that describe the API of a C library, including its

  • objects (GObjects, widgets, interfaces, boxed-types and plain structs)
  • functions
  • enums
  • signals
  • properties
  • vfuncs

At the moment, we have separate tools for generating different parts of these .defs, so we split them up into separate files. For instance, in the gtk/src directory of the gtkmm sources, you will find these files:

gtk.defs

Beinhaltet die andren Dateien.

gtk_methods.defs

Objekte und Funktionen.

gtk_enums.defs

Aufzählungen.

gtk_signals.defs

Signale und Eigenschaften.

gtk_vfuncs.defs

vfuncs (function pointer member fields in structs), written by hand.

G.2.1. Erzeugen der methods.defs

This .defs file describes objects and their functions. It is generated by the h2def.py script which you can find in glibmm's tools/defs_gen directory. For instance,

$ ./h2def.py /usr/include/gtk-3.0/gtk/*.h > gtk_methods.defs

G.2.2. Erzeugen der enums.defs

This .defs file describes enum types and their possible values. It is generated by the enum.pl script which you can find in glibmm's tools directory. For instance,

$ ./enum.pl /usr/include/gtk-3.0/gtk/*.h > gtk_enums.defs

G.2.3. Generating the signals and properties .defs

This .defs file describes signals and properties. It is generated by the special extra_defs utility that is in every wrapping project, such as gtkmm/tools/extra_defs_gen/. For instance

$ cd tools/extra_defs_gen
$ ./generate_extra_defs > gtk_signals.defs

You must edit the source code of your own generate_extra_defs tool in order to generate the .defs for the GObject C types that you wish to wrap. In the skeleton source tree, the source file is named codegen/extradefs/generate_extra_defs_skeleton.cc. If not done so already, the file should be renamed, with the basename of your new binding substituted for the skeleton placeholder. The codegen/Makefile.am file should also mention the new source filename.

Then edit the .cc file to specify the correct types. For instance, your main() function might look like this:

#include <libsomething.h>

int main(int, char**)
{
  something_init();

  std::cout << get_defs(EXAMPLE_TYPE_SOMETHING)
            << get_defs(EXAMPLE_TYPE_THING);
  return 0;
}

G.2.4. Schreiben der vfuncs.defs

This .defs file describes virtual functions (vfuncs). It must be written by hand. There is no skeleton to start from. You can look at gtkmm's gtk/src/gtk_vfuncs.defs file.