Ability to add annotation for zero-terminated array types
We have a type which is just a typedef to a C array of GeglColor
(which is a GObject
), zero-terminated:
typedef GeglColor** GimpColorArray;
Additionally it's registered as a boxed type.
When I have a function which returns this type or has it as parameter, it is pretty easy to just use the annotation (array zero-terminated=1)
on the function documentation-comment. That works well.
But we encountered the case with a function which returns a GValue, so multi-type. And this GValue can be sometimes a boxed GimpColorArray. In a binding, I want this to be transformed into the common representation for arrays, such as a list of GeglColor
in Python.
Unfortunately with pygobject, the generated object is useless. Python makes a generic object of type gobject.GBoxed
with which we cannot interact at all. I realized that it's because it doesn't know that it's nothing more than a zero-terminated array of objects.
Proposed solution
It would be good if we could add annotations to types. For instance, I'm thinking we could just have:
/**
* GimpColorArray: (array zero-terminated=1) (element-type GeglColor)
*
* A typedef alias for a %NULL-terminated array of [class@Gegl.Color].
*
* Since: 3.0
*/
GObject Introspection would store this information. This way, any binding could process GimpColorArray
data, even when it's not a direct arg or return value of an annotated function.
As as side effect, it would simplify annotations of such types (we won't have to write these annotations each and every time on any function using GimpColorArray
since it will be implied).