* GIWrapperBase::resolve: * * Include this in the Base::klass vtable if the class should support lazy * properties. If it is included, then there must be a corresponding * Prototype::resolve_impl() method. * * The *resolved out parameter, on success, should be false to indicate that * id was not resolved; and true if id was resolved. */
| 431 | * id was not resolved; and true if id was resolved. |
| 432 | */ |
| 433 | GJS_JSAPI_RETURN_CONVENTION |
| 434 | static bool resolve(JSContext* cx, JS::HandleObject obj, JS::HandleId id, |
| 435 | bool* resolved) { |
| 436 | Base* priv = Base::for_js(cx, obj); |
| 437 | |
| 438 | if (!priv) { |
| 439 | // This catches a case in Object where the private struct isn't set |
| 440 | // until the initializer is called, so just defer to prototype |
| 441 | // chains in this case. |
| 442 | // |
| 443 | // This isn't too bad: either you get undefined if the field doesn't |
| 444 | // exist on any of the prototype chains, or whatever code will run |
| 445 | // afterwards will fail because of the "!priv" check there. |
| 446 | debug_jsprop_static("Resolve hook", id, obj); |
| 447 | *resolved = false; |
| 448 | return true; |
| 449 | } |
| 450 | |
| 451 | priv->debug_jsprop("Resolve hook", id, obj); |
| 452 | |
| 453 | if (!priv->is_prototype()) { |
| 454 | // We are an instance, not a prototype, so look for per-instance |
| 455 | // props that we want to define on the JSObject. Generally we do not |
| 456 | // want to cache these in JS, we want to always pull them from the C |
| 457 | // object, or JS would not see any changes made from C. So we use |
| 458 | // the property accessors, not this resolve hook. |
| 459 | *resolved = false; |
| 460 | return true; |
| 461 | } |
| 462 | |
| 463 | const GjsAtoms& atoms = GjsContextPrivate::atoms(cx); |
| 464 | if (id_is_never_lazy(id, atoms)) { |
| 465 | *resolved = false; |
| 466 | return true; |
| 467 | } |
| 468 | |
| 469 | return priv->to_prototype()->resolve_impl(cx, obj, id, resolved); |
| 470 | } |
| 471 | |
| 472 | /** |
| 473 | * GIWrapperBase::finalize: |
nothing calls this directly
no test coverage detected