JS_GetInstancePrivate

この記事はまだ日本語に翻訳されていません。MDN の翻訳はボランティアによって行われています。是非 MDN に登録し、私たちの力になって下さい。

Retrieve the private data associated with an object, if that object is an instance of a specified class.

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. This must be one of the following:

  • an argv pointer created by the JavaScript engine and passed to a JSNative callback;
  • JS_ARGV(cx, vp) where vp is a pointer created by the engine and passed to a JSFastNative callback; or
  • NULL.

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.

See Also

MXR ID Search for JS_GetInstancePrivate

JSCLASS_HAS_PRIVATE, JSVAL_TO_PRIVATE, JS_GetPrivate, JS_InitClass, JS_InstanceOf, JS_ReportError, JS_SetPrivate

Document Tags and Contributors

Contributors to this page: Tservo, MMondor, Nickolay, Jorend, Dria
最終更新者: Jorend,