mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 766378 - adds a createArrayIn() call to create JS arrays in a given scope [r=mrbkap]
This commit is contained in:
parent
7ff49f22ce
commit
7a73ff8ad0
@ -285,6 +285,14 @@ interface nsIXPCComponents_Utils : nsISupports
|
||||
[implicit_jscontext]
|
||||
jsval createObjectIn(in jsval vobj);
|
||||
|
||||
/*
|
||||
* To be called from JS only.
|
||||
*
|
||||
* Returns an array created in |vobj|'s compartment.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
jsval createArrayIn(in jsval vobj);
|
||||
|
||||
/*
|
||||
* To be called from JS only.
|
||||
*
|
||||
|
@ -4129,6 +4129,35 @@ nsXPCComponents_Utils::CreateObjectIn(const jsval &vobj, JSContext *cx, jsval *r
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* jsval createObjectIn(in jsval vobj); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::CreateArrayIn(const jsval &vobj, JSContext *cx, jsval *rval)
|
||||
{
|
||||
if (!cx)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// first argument must be an object
|
||||
if (JSVAL_IS_PRIMITIVE(vobj))
|
||||
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||
|
||||
JSObject *scope = js::UnwrapObject(JSVAL_TO_OBJECT(vobj));
|
||||
JSObject *obj;
|
||||
{
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(cx, scope))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
obj = JS_NewArrayObject(cx, 0, NULL);
|
||||
if (!obj)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!JS_WrapObject(cx, &obj))
|
||||
return NS_ERROR_FAILURE;
|
||||
*rval = OBJECT_TO_JSVAL(obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSBool
|
||||
FunctionWrapper(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user