GObject.TYPE_BOXED

GObject.TYPE_BOXED represents the GBoxed type in the GObject type system. You can pass this object to methods taking a GObject.Type.

The GBoxed type is the base type for all boxed types (structures and unions that are not derived from GObject.Object). It is not a value type, so it has no representation in gjs as such, and it cannot be used in signal arguments or property values directly.

Not all JS classes are derived from GBoxed, for example they may be new fundamental types. You can check if this is the case with GObject.type_is_a(My.StructType, GObject.TYPE_BOXED).

In JS, boxed types are represented with weak wrappers, which means that every time a boxed type is converted from C to JS (for example as a function call result) a different JS object is created. This means that the same underlying C structure can be represented by multiple objects at times, so JS boxed wrappers should never be compared by value and should not have any JS visible state (for example custom properties), because it can be lost at any time.

JS boxed wrappers will be garbage collected independently of the underlying C structure. Additionally, dependening on the implementation of the boxed type (copied value type or reference type), as well as the transfer mode of the function from which the value is obtained, the boxed type may be a copy of the original C structure, so even C visible state (such as method calls that modify the instance) may not affect the right object.

In practice, this means that you should treat all boxed types as immutable, unless you are sure of the reference-counting semantics or you created the structure youself with the appropriate constructor.