GNOME Bugzilla – Bug 673422
Babl C type not accessible to introspection bindings
Last modified: 2013-10-09 17:45:02 UTC
Created attachment 211212 [details] [review] Fix build of introspection The build of introspection data for babl fails. This is mostly because the main type in babl is Babl, which is also the namespace. That's confusing for g-i. I'm attaching a patch that seems to fix things, and that I believe is correct. CC'ing Colin so that he can confirm. However, what's broken now is the generation of the vala bindings...
For reference, the error for generating vala bindings is: Babl-0.1.gir:160.31-160.31: error: `' is not a type <type name="Babl" c:type="Babl*"/> ^
We could let the C type "Babl" have the GI namespace "Babl" and type name "Fish". I think that should be possible to annotate. It would make this into a standard GI API in terms of naming, and also be extensible in case a C type BablSomething is added. Øyvind, what do you think?
The C type const Babl is used for two different things in the core use of Babl's public API. 1) const Babl *babl_format ("R'G'B'A u8"); /* get a singleton reference/pointer to a description of a pixel format representation */ These are the core parts of Babl that need to be bound and understood by bindings to make them useful also for general use with GeglBuffers. Some other things like getting the string name back out from a Babl format would probably be easy once that works. 2) Less important for bindings, but neccesary to unleash the full power is creating conversions (babl fishes) between these formats and using them: const Babl *babl_fish (const Babl *src_format, const Babl *dst_format); /* get a singleton reference to a babl conversion */ The fish is used by babl_process (const Babl *fish, void *src_data, void *dst_data, long n_pixels);
Babl.Fish is not a good name then since only in the more uncommon usecase it represents a conversion/translation. We could annotate it to be renamed to Babl.Babl of course, unless someone has better suggestions?
Using the "Rename to: BablObject" annotation as described on http://live.gnome.org/GObjectIntrospection/Annotations#Rename_to does not make any difference to the generated .gir. Manually editing the Babl type record to be "<record name="Object" c:type="Babl">", and its use to be and <type name="Object" c:type="Babl*"/>, makes the .typelib compile successfully.
Another possibly related issue is that for all the methods for the Babl* c-type, the first character is stripped from the name in the GIR: <method name="alette_reset" c:identifier="babl_palette_reset">
Review of attachment 211212 [details] [review]: When applying this patch, the C functions operating on or creating a Babl* are no longer recognized as methods and constructors.
commit dc754cdd46bf89506ccbacd9e1edf4f18319ba6f Author: Jon Nordby <jononor@gmail.com> Date: Fri Jul 27 22:00:46 2012 +0200 Bug 673422 - Babl C type not accessible to introspection bindings https://bugzilla.gnome.org/show_bug.cgi?id=673422 Annotate Babl C type to be Babl.Object in GIR using the "rename to" annotation in GI 1.33.5+. For earlier versions, use a static .gir file to achieve the same.
Not fixed as the dependent fixes were reverted in GI.
All instances of Babl * now have alternate wrappers in GEGL's bindings, so not having Babl bindings is no longer an impediment to using GEGL from Python. Is there a real use case for introspecting Babl outside of GEGL? It seems like a lot more pain than it's worth.
No, probably not, closing. Thanks for fixing the GEGL introspection! We should rip out the --enable-introspection in Babl automake, if not done already.