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 jschar * or jsid 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.