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

Method add_property

gi/object.cpp:250–263  ·  view source on GitHub ↗

A hook on adding a property to an object. This is called during a set * property operation after all the resolve hooks on the prototype chain have * failed to resolve. We use this to mark an object as needing toggle refs when * custom state is set on it, because we need to keep the JS GObject wrapper * alive in order not to lose custom "expando" properties. */

Source from the content-addressed store, hash-verified

248 * alive in order not to lose custom "expando" properties.
249 */
250bool ObjectBase::add_property(JSContext* cx, JS::HandleObject obj,
251 JS::HandleId id, JS::HandleValue value) {
252 auto* priv = ObjectBase::for_js(cx, obj);
253
254 // priv is null during init: property is not being added from JS
255 if (!priv) {
256 debug_jsprop_static("Add property hook", id, obj);
257 return true;
258 }
259 if (priv->is_prototype())
260 return true;
261
262 return priv->to_instance()->add_property_impl(cx, obj, id, value);
263}
264
265bool ObjectInstance::add_property_impl(JSContext* cx, JS::HandleObject obj,
266 JS::HandleId id, JS::HandleValue) {

Callers

nothing calls this directly

Calls 3

is_prototypeMethod · 0.80
add_property_implMethod · 0.80
to_instanceMethod · 0.80

Tested by

no test coverage detected