Toward GIR ? #27

Closed
vmagnin opened this Issue May 23, 2011 · 0 comments

Projects

None yet

1 participant

@vmagnin
Collaborator
vmagnin commented May 23, 2011

Currently, we use regular expressions to parse the C header files of the libraries (see cfwrapper.py and extract_events.pl). GIR files could be an alternative. This is opened to discussion.

I have begun playing with the ElementTree module in python to parse the GIR files that can be found in /usr/share/gir-1.0/ :

Atk-1.0.gir        GdkPixbuf-2.0.gir  Gtk-3.0.gir         PangoXft-1.0.gir
Epiphany-2.29.gir  GdkX11-2.0.gir     Pango-1.0.gir       Unity-3.0.gir
Gdk-2.0.gir        GdkX11-3.0.gir     PangoCairo-1.0.gir
Gdk-3.0.gir        Gtk-2.0.gir        PangoFT2-1.0.gir

These GIR files are XML files that describe the functions, structures, constants, etc. that are in these libraries (see http://live.gnome.org/GObjectIntrospection).

For other libraries like GLib, you may generate the GIR file using the .typelib file in /usr/gir/girepository-1.0 (you need the gobject-introspection package):

g-ir-generate /usr/lib/girepository-1.0/GLib-2.0.typelib > glib.xml

But in that case, there is no "c:identifier" attribute in the tag (how to identify a pointer ?)

Advantages:

  • parsing XML is easier than using regular expressions which must take into account many exceptions and peculiarities.
  • The binding would be more complete (to what extent ?).

Drawbacks:

  • GIR format is not well documented.
  • Cairo is not (yet ?) supported. So cfwrapper.py would still be necessary at least for it. Probably also for others like GLib (see the "c:identifier" problem above).
  • We would lose the C prototypes in comments and also in gtk-fortran-index.csv
  • A new effort.

The question is: is it worth while ? Or would it be more adequate to improve cfwrapper.py ?

See also http://mkestner.blogspot.com/2011/02/signs-of-life.html on the gtk-sharp binding. After installing the gobject-introspection package under Ubuntu, we have the python file /usr/lib/gobject-introspection/giscanner/girparser.py which we could perhaps use to parse the gir files.

@vmagnin vmagnin was assigned May 23, 2011
@vmagnin vmagnin closed this Dec 7, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment