JSResolveOp 编辑
JSResolveOp is the type of the JSClass.resolve
.
Syntax
typedef bool
(* JSResolveOp)(JSContext *cx, JS::HandleObject obj,
JS::HandleId id, bool *resolvedp); // Added in JSAPI 36
typedef bool
(* JSResolveOp)(JSContext *cx, JS::HandleObject obj,
JS::HandleId id); // Obsolete since JSAPI 36
Name | Type | Description |
---|---|---|
cx | JSContext * | Pointer to the JS context in which the property access is taking place. |
obj | JS::HandleObject | Pointer to the object whose properties are being accessed. |
id | JS::HandleId | The name or index of the property being resolved. |
resolvedp | bool * | Out parameter. Receives the result of resolve operation. |
Description
JSResolveOp
callback is a hook which is called when a property is not found on an object.
It resolves a lazy property named by id
in obj
by defining it directly in obj
. Lazy properties are those reflected from some peer native property space (e.g., the DOM attributes for a given node reflected as obj
) on demand.
The callback must set *resolvedp
to true
and return true
if the property is resolved, or set *resolvedp
to false
and return true
if the object has no lazy property with the given id
; or return false
to indicate any other error.
Obsolete since JSAPI 36
The callback must return true
if the property is resolved, or if the object has no lazy property with the given id
; or false
to indicate any other error.
Note: JSNewResolveOp
provides a cheaper way to resolve lazy properties.
JSClass hooks
JSClass offers the following hook:
JSClass.resolve
callback is called when a property is not found on an object. It can be used to implement lazy properties.JS looks for a property in an object, and if not found, tries to resolve the given
id
. After callingresolve
, the engine looks again to see ifresolve
definedobj[id]
. If so, the property lookup succeeds. If not, the process is repeated withobj
's prototype.
See Also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论