JS_GetPropertyAttrsGetterAndSetter 编辑
Obsolete since JSAPI 26
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Retrieve the attributes, getter, and setter of a specified property.
Syntax
JSBool
JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
const char *name, unsigned int *attrsp, JSBool *foundp,
JSPropertyOp *getterp, JSPropertyOp *setterp);
JSBool
JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
const jschar *name, size_t namelen,
unsigned int *attrsp, JSBool *foundp,
JSPropertyOp *getterp, JSPropertyOp *setterp);
JSBool
JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *obj,
jsid id, unsigned int *attrsp, JSBool *foundp,
JSPropertyOp *getterp, JSPropertyOp *setterp); // Added in SpiderMonkey 1.8.1
Name | Type | Description |
---|---|---|
cx | JSContext * | The context in which to perform the property lookup. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext . |
obj | JSObject * | Object from which to retrieve property attributes. |
name or id | const char * or const | The name of the property to examine. |
namelen | size_t | (only in JS_GetUCPropertyAttrsGetterAndSetter ) The length of name in characters; or (size_t) -1 to indicate that name is null-terminated. |
attrsp | unsigned int * | Out parameter. Pointer to the storage area into which to place retrieves attributes. |
foundp | JSBool * | Out parameter. Flag indicating whether or not the specified property was located. |
getterp | JSPropertyOp * | Out parameter. On success, *getterp receives a pointer to the getter function for the specified property. |
setterp | JSPropertyOp * | Out parameter. On success, *setterp receives a pointer to the setter function for the specified property. |
Description
See JS_GetPropertyAttributes
for details about these functions. The only difference is that on success, these functions also get the getter and setter functions for the property.
The JS_GETTER
(or JS_SETTER
) attribute indicates that the property's getter (or setter) is a JavaScript function, not a C/C++ function. When this attribute is present, the value stored in getterp
(or setterp
) does not really point to a C/C++ function; it is a JSObject *
, pointing to a JavaScript function, cast to type JSPropertyOp
. The application may cast it back to JSObject *
(using a C cast or a C++ reinterpret_cast
) to access the getter/setter function object. For more information about JavaScript getters and setters, see Defining Getters and Setters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论