function ref_sink(): GLib.Variant {
    // Gjs wrapper for g_variant_ref_sink()

GLib.Variant uses a floating reference count system. All functions with names starting with `g_variant_new_` return floating references.

Calling GLib.Variant.prototype.ref_sink on a GLib.Variant with a floating reference will convert the floating reference into a full reference. Calling GLib.Variant.prototype.ref_sink on a non-floating GLib.Variant results in an additional normal reference being added.

In other words, if the value is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference. If the value is not floating, then this call adds a new normal reference increasing the reference count by one.

All calls that result in a GLib.Variant instance being inserted into a container will call GLib.Variant.prototype.ref_sink on the instance. This means that if the value was just created (and has only its floating reference) then the container will assume sole ownership of the value at that point and the caller will not need to unreference it. This makes certain common styles of programming much easier while still maintaining normal refcounting semantics in situations where values are not floating.

Since 2.24


the same value