This article covers features introduced in SpiderMonkey 31
Root an internal fixed-size array of JS::Values.
Syntax
JS::AutoValueArray<N> vp(cx);
| Name | Type | Description | 
|---|---|---|
| cx | JSContext * | The context in which to add the root. Requires request. In a JS_THREADSAFEbuild, the caller must be in a request on thisJSContext. | 
| N | size_t | Size of a JS::Valuearray. | 
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);