Generar los archivos .defs.

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:


Includes the other files.


Objects and functions.




Signals and properties.


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

The skeletonmm/codegen/ script generates all .defs files and the *_docs.xml file, described in the Documentation section.

G.2.1. Generar los .defs de métodos

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

$ ./ /usr/include/gtk-4.0/gtk/*.h > gtk_methods.defs

G.2.2. Generar los .defs de enumeraciones

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

$ ./ /usr/include/gtk-4.0/gtk/*.h > gtk_enums.defs

G.2.3. Generar los .defs de señales y propiedades

This .defs file describes signals and properties. It is generated by the special generate_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

Debe editar el código fuente de su herramienta generate_extra_defs para generar los .defs para los tipos GObject de C que desea envolver. En el árbol de fuentes esqueleto, el archivo de fuentes se llama codegen/extradefs/ Si no lo ha hecho todavía, debe renombrar el archivo, con el nombre de base de su enlace nuevo sustituyendo a la marca de posición skeleton. El archivo codegen/ también debe mencionar el nombre del archivo de fuentes nuevo.

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

  std::cout << get_defs(SOME_TYPE_WIDGET)
            << get_defs(SOME_TYPE_STUFF);
  return 0;

G.2.4. Escribir los .defs de las «vfuncs»

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