2 #ifndef nsDOMJSUtils_h__
3 #define nsDOMJSUtils_h__
6 #include "nsIScriptContext.h"
8 // seems like overkill for just this 1 function - but let's see what else
10 inline nsIScriptContext
*
11 GetScriptContextFromJSContext(JSContext
*cx
)
13 if (!(::JS_GetOptions(cx
) & JSOPTION_PRIVATE_IS_NSISUPPORTS
)) {
17 nsCOMPtr
<nsIScriptContext
> scx
=
18 do_QueryInterface(static_cast<nsISupports
*>
19 (::JS_GetContextPrivate(cx
)));
21 // This will return a pointer to something that's about to be
22 // released, but that's ok here.
26 // A factory function for turning a jsval argv into an nsIArray
27 // but also supports an effecient way of extracting the original argv.
28 // Bug 312003 describes why this must be "void *", but argv will be cast to
29 // jsval* and the args are found at:
30 // ((jsval*)aArgv)[0], ..., ((jsval*)aArgv)[aArgc - 1]
31 // The resulting object will take a copy of the array, and ensure each
33 // Optionally, aArgv may be NULL, in which case the array is allocated and
34 // rooted, but all items remain NULL. This presumably means the caller will
35 // then QI us for nsIJSArgArray, and set our array elements.
36 nsresult
NS_CreateJSArgv(JSContext
*aContext
, PRUint32 aArgc
, void *aArgv
,
39 #endif // nsDOMJSUtils_h__