object: Try to use parent GType's GI infos if none is found

Closed Marco Trevisan requested to merge 3v1n0/gjs:info-find-in-gtype-parents into master

If current object info is not exposed by GI repository data, we were unable to get object properties unless if they were exposed by the interfaces implemented by the GType.

However, we could still be able to access to properties and in particular vfunc's and methods by looking at the first valid parent gtype infos.

An example are the GSettings backends, in fact gir only exposes public classes but it's not possible to define or override virtual functions because such methods are not found in the type.

const { Gio, GLib, GObject } = imports.gi;

const backend = Gio.SettingsBackend.get_default();

const MyBackend = GObject.registerClass(
class MyBackend extends backend.constructor {
  vfunc_read(...args) {
    return super.vfunc_read(...args);

const myBackend = new MyBackend();
print(myBackend.vfunc_read("foo", new GLib.VariantType('s'), false))


Before of this was failing with:

(gjs:1944332): Gjs-CRITICAL **: 04:28:13.527: JS ERROR: Error: Virtual function not implemented: Class GSettingsBackend doesn't implement read

Merge request reports