Skip to content

giscanner / girepository: Add support for static virtual functions

Marco Trevisan requested to merge 3v1n0/gobject-introspection:static-vfuncs into main

We have a number of virtual functions in both interfaces and classes that are de-facto static methods that can be implemented to be used as factory or other similar behavior.

These are currently not supported by bindings even though it's quite simple to support them and many languages (including JS and python) support static methods.

So, allow introspecting callbacks that do not contain an instance parameter, and threat them as static virtual functions. In such case, we expose all the parameters to gir.

Also fix the case where the first argument was matching the instance type but its direction state was not supported (and thus anything that is not (in)).

The writer handles this by adding a static="1" attribute to the node. This is technically not needed by girepository library as it may just rely on the fact that if a virtual-function argument is an instance parameter, then such vfunc is not static. However, it makes things clearer and easier to catch for humans.

Added some test implementation to GIMarshallingTests and Regress too.


Gjs implementation is also ready: gjs!802

Edited by Marco Trevisan

Merge request reports