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. */
| 248 | * alive in order not to lose custom "expando" properties. |
| 249 | */ |
| 250 | bool 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 | |
| 265 | bool ObjectInstance::add_property_impl(JSContext* cx, JS::HandleObject obj, |
| 266 | JS::HandleId id, JS::HandleValue) { |
nothing calls this directly
no test coverage detected