Bug 930910 - options object for Cu.createObjectIn. r=bholley

This commit is contained in:
Gabor Krizsanits 2013-11-05 08:00:05 +01:00
Родитель a64a8df71b
Коммит e1c20812c6
2 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -120,7 +120,7 @@ interface ScheduledGCCallback : nsISupports
/**
* interface of Components.utils
*/
[scriptable, uuid(08a49c33-0704-4b88-bebb-9a0cf1309f30)]
[scriptable, uuid(190257e4-64ad-4a5a-8c99-a1166aeaf7a1)]
interface nsIXPCComponents_Utils : nsISupports
{
@ -311,9 +311,11 @@ interface nsIXPCComponents_Utils : nsISupports
* To be called from JS only.
*
* Returns an object created in |vobj|'s compartment.
* If defineAs property on the options object is a non-null ID,
* the new object will be added to vobj as a property.
*/
[implicit_jscontext]
jsval createObjectIn(in jsval vobj);
jsval createObjectIn(in jsval vobj, [optional] in jsval voptions);
/*
* To be called from JS only.

Просмотреть файл

@ -3046,11 +3046,20 @@ xpc::CreateObjectIn(JSContext *cx, HandleValue vobj, CreateObjectInOptions &opti
return true;
}
/* jsval createObjectIn(in jsval vobj); */
/* jsval createObjectIn(in jsval vobj, [optional] in jsval voptions); */
NS_IMETHODIMP
nsXPCComponents_Utils::CreateObjectIn(const Value &vobj, JSContext *cx, Value *rval)
nsXPCComponents_Utils::CreateObjectIn(const Value &vobj, const Value &voptions,
JSContext *cx, Value *rval)
{
CreateObjectInOptions options;
RootedObject optionsObject(cx, voptions.isObject() ? &voptions.toObject()
: nullptr);
CreateObjectInOptions options(cx, optionsObject);
if (voptions.isObject() &&
!options.Parse())
{
return NS_ERROR_FAILURE;
}
RootedValue rvobj(cx, vobj);
RootedValue res(cx);
if (!xpc::CreateObjectIn(cx, rvobj, options, &res))