JS GetInstancePrivate
From MDC
Retrieve the private data associated with an object, if that object is an instance of a specified class.
[edit] Syntax
void * JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv);
| Name | Type | Description |
|---|---|---|
cx |
JSContext * |
A context. |
obj |
JSObject * |
The object for which to retrieve private data. |
clasp |
JSClass * |
Class against which to test the object. |
argv |
jsval * |
Optional argument vector, used for error reporting, or NULL. If non-null, this must be an argv pointer created by the JavaScript engine and passed to a JSNative or JSFastNative callback. |
[edit] Description
JS_GetInstancePrivate determines if a JavaScript object, obj, is an instance of a given JSClass, clasp, and if it is, returns a pointer to the object's private data. Otherwise it returns NULL.
Note that if obj is an instance of clasp, but there is no private data currently associated with the object, or the object cannot have private data, JS_GetInstancePrivate also returns NULL.
If you pass a non-null argument vector, argv, to JS_GetInstancePrivate, and obj is not an instance of clasp, this function reports a class mismatch error before returning NULL. In this case, JS_GetInstancePrivate tests whether or not there is a function name associated with the argument vector, and if there is, reports the name in an error message using the JS_ReportError function.
[edit] See Also
LXR ID Search for JS_GetInstancePrivate
JSCLASS_HAS_PRIVATE, JSVAL_TO_PRIVATE, JS_GetPrivate, JS_InitClass, JS_InstanceOf, JS_ReportError, JS_SetPrivate