JS_GetInstancePrivate 编辑
Retrieve the private data associated with an object, if that object is an instance of a specified class.
Syntax
void *
JS_GetInstancePrivate(JSContext *cx, JS::Handle<JSObject*> obj,
const JSClass *clasp, JS::CallArgs *args); // Added in JSAPI 32
void *
JS_GetInstancePrivate(JSContext *cx, JS::Handle<JSObject*> obj,
const JSClass *clasp, jsval *argv); // Obsolete since JSAPI 32
Name | Type | Description |
---|---|---|
cx | JSContext * | A context. |
obj | JS::Handle<JSObject*> | The object for which to retrieve private data. |
clasp | JSClass * | Class against which to test the object. |
args | JS::CallArgs * | Optional argument, used for error reporting. Added in SpiderMonkey 32 |
argv | jsval * | Optional argument vector, used for error reporting. Obsolete since JSAPI 32 This must be one of the following:
|
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论