JS::AutoValueArray 编辑
This article covers features introduced in SpiderMonkey 31
Root an internal fixed-size array of JS::Value
s.
Syntax
JS::AutoValueArray<N> vp(cx);
Name | Type | Description |
---|---|---|
cx | JSContext * | The context in which to add the root. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext . |
N | size_t | Size of a JS::Value array. |
Description
JS::AutoValueArray<N>
holds a rooted array of JS::Value
. This is typically used for local variables being passed to function which requires JS::HandleValueArray
or a pointer to JS::Value
array.
Examples
Pass to function as a pointer to JS::Value
.
bool
someFunction1(JSContext *cx, unsigned argc, const JS::Value *argv) {
/* ... */
}
JS::AutoValueArray<2> args(cx);
/* ... Initialize args[0] and args[1] here ... */
someFunction1(cx, 2, args.begin());
Pass to function as JS::HandleValueArray
.
bool
someFunction2(JSContext *cx, const JS::HandleValueArray &args) {
/* ... */
}
JS::AutoValueArray<2> args(cx);
/* ... Initialize args[0] and args[1] here ... */
someFunction2(cx, args);
See Also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论