[GObject Introspection] How not to associate a function to a class with same name?

The title question may not be clear, so I have an example: in GIMP public API, we have the class GimpPath which is a path item in the meaning of a vector object.

Now “path” is often used for meaning a path on file system too, and for instance, the utils function `gimp_path_parse() is about such a usage of “path”.

Unfortunately I realize that GObject Introspection associates this function to the GimpPath class mistakenly, which is weird (even if I guess the function will still work fine).

Is there an annotation to force gimp_path_parse() to be Gimp.path_parse (i.e. just a path_parse function under the Gimp module)? I searched in docs but couldn’t find this.

Thanks! :hugs:

It’s kind of hard to do, because turning gimp_path_parse() into Gimp.path_parse() would also imply turning things like Gdk.RGBA.parse() into Gdk.rgba_parse(), which is definitely something we do not want.

We don’t have a not method annotation, at the moment, and introducing one is still not entirely enough.

The issue, here, is that the function should have been called gimp_parse_path() to begin with. :wink: This would have avoided the matching to the longest substring.

My suggestion to fix this issue:

  1. introduce gimp_parse_path()
  2. deprecate gimp_path_parse()

If you want to hide gimp_path_parse() from the introspection data, then you can surround its declaration with a check on the __GI_SCANNER__ symbol:

#ifndef __GI_SCANNER__
GList *gimp_path_parse (...);
#endif

This will keep the symbol when using the C API, but will hide the declaration when generating the introspection data.

Removing or renaming a symbol in the introspection data is an IABI (introspection ABI) break, so you may want to skip this, in any case.

Yeah. I think it is completely fine that this association is made by default (both the Gimp.Path.parse() and Gdk.RGBA.parse()). So I’m really not advocating against this; just to have a voluntary way of opting out of it.

I guess it could be e.g. a (instrospect-as Gimp.path_parse) annotation? (or named something else; I’m not always the best to name things!)

Or maybe (not Gimp.Path) to use a similar naming as your (not method) proposed annotation, to explicitly say that this is not to be put into the Gimp.Path API. :person_shrugging:

Indeed. From reading the MR, it doesn’t look like the same issue either since Gimp.Path.parse is not considered a Gimp.Path object method either anyway, more like a class function. And there is no Gimp.Path argument (first one or otherwise!) into this function signature.

Sure. I don’t deny that this could have been caught earlier and renamed appropriately. :sweat_smile: To be fair, this function has existed in GIMP since forever (it has been introduced in 2000!), while we only started using GObject-Introspection for GIMP 3 in 2025.

Anyway, we could play a deprecation+renaming game of course, as you suggest, but I would really have preferred a way to annotate that it’s just not part of Gimp.Path API. Because other than for GObject-Introspection, this method name is not entirely wrong either and we are really trying to avoid breaking existing people scripts unnecessarily (well a deprecation does not break the script but adds some warning, which is annoying on its own). :confused:

Anyway I’ll think further, maybe do what you suggest, or maybe propose an annotation request, or maybe just nothing as time permits. :grin:

I’ll end in a completely unrelated question (sorry!) which was triggered by your last proposition:

We have one piece of code which is only compiled when building for macOS:

gimp_app_permissions = @{(__bridge id)kAXTrustedCheckOptionPrompt: @YES};

And that triggers this annoying warning twice when generating the GIR (on any platform):

[7/16] Generating libgimp/GimpUi-3.0.gir with a custom command (wrapped by meson to set env)
/home/jehan/dev/src/gimp/libgimp/gimpui.c:750: unexpected character `@'
/home/jehan/dev/src/gimp/libgimp/gimpui.c:750: unexpected character `@'

We have been looking for how to get rid of it (well not me much personally). When I saw your piece of code above, I hoped that wrapping in #ifndef __GI_SCANNER__ would work, but apparently not.

Is there a trick to hide such code from GIR tools and get back to a warning-less build! :sweat_smile:

P.S.: also to just hide a function from introspection data, why don’t you just suggest using (skip)?