JS_GetReservedSlot 编辑
Access an object's reserved slots.
Syntax
// Added in SpiderMonkey 42
JS::Value
JS_GetReservedSlot(JSObject *obj, uint32_t index);
void
JS_SetReservedSlot(JSObject *obj, uint32_t index, JS::Value v);
// Obsolete since SpiderMonkey 42
jsval
JS_GetReservedSlot(JSObject *obj, uint32_t index);
void
JS_SetReservedSlot(JSObject *obj, uint32_t index, jsval v);
Name | Type | Description |
---|---|---|
obj | JSObject * | An object that has reserved slots. |
index | uint32_t | Index of the reserved slot to access. |
v | JS::Value | (in JS_SetReservedSlot ) The value to store. |
Description
If a JSClass
has JSCLASS_HAS_RESERVED_SLOTS(n)
in its flags
, with n > 0, or has a non-null JSClass.reserveSlots
callback, then objects of that class have n
reserved slots in which the application may store data. These fields are not directly exposed to scripts.
Reserved slots may contain any JS::Value
, and the garbage collector will hold the value alive as long as the object itself is alive.
Reserved slots may also contain private values to store pointer values (whose lowest bit is 0) or uint32_t
, when non-JavaScript values must be stored; the garbage collector ignores such values when it sees them. (Note that private values must not be exposed directly to JavaScript. It's only legal to store and retrieve data from private values. They cannot be returned from functions, set as properties on objects, embedded in JavaScript arrays, and so on.)
New objects' reserved slots are initialized to undefined
.
See Also
- MXR ID Search for
JS_GetReservedSlot
- MXR ID Search for
JS_SetReservedSlot
- bug 1184564 -- Changed jsval to JS::Value
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论