GNOME Bugzilla – Bug 584683
GIR: add vapi annotation
Last modified: 2010-02-01 16:00:50 UTC
One of the GIR features missing in Vala's handling of reading and writing GIR files is <include/> support. I propose that a new annotation for namespaces be added, specifically for GIR support. Example (gobject-2.0.vapi): [GIR (namespace = "GObject", version = "2.0")] [CCode (cprefix = "G", lower_case_cprefix = "g_", cheader_filename = "glib.h")] namespace GLib { // ... } There are three methods to determine the values of the annotations: 1. Manually (when hand-writing vapi files) 2. Via package.metadata, "gir_namespace" and "gir_version" (when giving vapigen a GI file) 3. Automatically parsed from the GIR file (when giving vapigen a GIR file) The main advantage to this approach that I see is that it avoids the need for valac to call `pkg-config` multiple times to determine the GIR namespace(s) and version(s) of the library's dependencies. (see bug 577347). This would also avoid having to make namespace exceptions in gir reading/writing (such as my attachment 133005 [details] [review] in bug 559704).
Created attachment 139569 [details] [review] add GIR annotation for vala and vapi files Adds support for both parsing and writing the GIR annotation for Vala files. The annotation is meant to be applied to namespaces only in vala/vapi files, and the GIR metadata is propagated to the child symbols by the namespace. The special casing for GObject.Object GIR namespace has been removed. All symbols now have a GIR namespace property, used when the Vala namespace does not match the GIR namespace. All namespaces now have a GIR namespace version property, used when writing the GIR dependencies in a library's GIR file. There are also namespace metadata annotations added: gir_namespace and gir_version (see gdk-pixbuf-2.0.metadata for an example). Adds the proper GIR namespaces for gobject-2.0, cairo, and gdk-pixbuf-2.0.
Created attachment 141300 [details] [review] Update original patch If i understood IRC correctly this needed switching to use [CCodeNode] instead of [Gir], so i had a go. Rather than propogate gir_namespace to a load of classes i added get_gir_namespace which walks parent_symbol until it finds a namespace or a wall - not sure if this is the best idea or if it even works but it at least builds :)
[Doh, fails to link though]
Created attachment 152697 [details] [review] Updated patch This is my latest version of the patch after much reworking. Now we store the namespace and version as properties on SourceFile, this allows us to split a vala namespace into multiple GIR namespaces. It now correctly outputs <include> lines for the api dependancies, and warns if dependent namespaces havn't been annotated.
Ah, no, still not final. There's a bug where it writes multiple <include> tags. Patch coming up.
Created attachment 152719 [details] [review] Updated patch This version fixes the multiple <include> problem and adds annotations for some core vapis.
commit 7dcc676f1782a18fccfdf5203ef809e4aa6c19c9 Author: Rob Taylor <rob.taylor@codethink.co.uk> Date: Sun Jan 31 16:11:00 2010 +0000 GIR Namespace support This patch introduces two new CCode annotations for use in VAPI files, gir_namespace and gir_version. This allows us to correctly map vala namespaces to gobject-introspection namespaces when generating GIR files. The mapping is actually done on a SourceFile level. This allows us to work around cases where one vala namespace maps into multiple GIR namespaces (in particular, GLib vs GLib and GObject). In the absense of annotations, the old 'guess it' method will be applied. This commit also adds annotations to some core vapis. Fixes bug 584683.