MCPcopy Create free account
hub / github.com/GNOME/gjs / finalize

Method finalize

gi/wrapperutils.h:480–498  ·  view source on GitHub ↗

* GIWrapperBase::finalize: * * This should always be included in the Base::klass vtable. The destructors * of Prototype and Instance will be called in the finalize hook. It is not * necessary to include a finalize_impl() function in Prototype or Instance. * Any needed finalization should be done in ~Prototype() and ~Instance(). */

Source from the content-addressed store, hash-verified

478 * Any needed finalization should be done in ~Prototype() and ~Instance().
479 */
480 static void finalize(JS::GCContext* gcx, JSObject* obj) {
481 Base* priv = Base::for_js_nocheck(obj);
482 if (!priv)
483 return; // construction didn't finish
484
485 // Call only GIWrapperBase's original method here, not any overrides;
486 // e.g., we don't want to deal with a read barrier in ObjectInstance.
487 static_cast<GIWrapperBase*>(priv)->debug_lifecycle(obj, "Finalize");
488
489 if (priv->is_prototype()) {
490 GType gtype = priv->to_prototype()->gtype();
491 remove_prototype_associated_memory(gtype, obj);
492 priv->to_prototype()->finalize_impl(gcx, obj);
493 } else {
494 priv->to_instance()->finalize_impl(gcx, obj);
495 }
496
497 Base::unset_private(obj);
498 }
499
500 /**
501 * GIWrapperBase::trace:

Callers

nothing calls this directly

Calls 7

is_prototypeMethod · 0.80
to_prototypeMethod · 0.80
to_instanceMethod · 0.80
debug_lifecycleMethod · 0.45
gtypeMethod · 0.45
finalize_implMethod · 0.45

Tested by

no test coverage detected