1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef nsDOMJSUtils_h__
8 #define nsDOMJSUtils_h__
9 
10 #include "nsIScriptContext.h"
11 #include "jsapi.h"
12 
13 class nsIJSArgArray;
14 
15 // A factory function for turning a JS::Value argv into an nsIArray
16 // but also supports an effecient way of extracting the original argv.
17 // The resulting object will take a copy of the array, and ensure each
18 // element is rooted.
19 // Optionally, aArgv may be nullptr, in which case the array is allocated and
20 // rooted, but all items remain nullptr.  This presumably means the caller
21 // will then QI us for nsIJSArgArray, and set our array elements.
22 nsresult NS_CreateJSArgv(JSContext* aContext, uint32_t aArgc,
23                          const JS::Value* aArgv, nsIJSArgArray** aArray);
24 
25 #endif  // nsDOMJSUtils_h__
26