Bug 965751 - Deprecate ObjectWrapper.jsm, r=bholley, f=fabrice

This commit is contained in:
Andrea Marchesini 2014-01-30 11:39:46 -08:00
parent 84585a7828
commit a1787b5d9b

View File

@ -46,44 +46,7 @@ this.ObjectWrapper = {
},
wrap: function objWrapper_wrap(aObject, aCtxt) {
// First check wich kind of object we have.
let kind = this.getObjectKind(aObject);
if (kind == "array") {
let res = Cu.createArrayIn(aCtxt);
aObject.forEach(function(aObj) {
res.push(this.wrap(aObj, aCtxt));
}, this);
return res;
} else if (TypedArrayThings.indexOf(kind) !== -1) {
// This is slow, because from the perspective of the constructor in aCtxt
// aObject is a CCW, and it gets the indexed properties one by one rather
// instead of realizing that this is already a typed array thing.
return new aCtxt[kind](aObject);
} else if (kind == "file") {
return new aCtxt.File(aObject,
{ name: aObject.name,
type: aObject.type });
} else if (kind == "blob") {
return new aCtxt.Blob([aObject], { type: aObject.type });
} else if (kind == "date") {
return Cu.createDateIn(aCtxt, aObject.getTime());
} else if (kind == "primitive") {
return aObject;
}
// Fall-through, we now have a dictionnary object.
let res = Cu.createObjectIn(aCtxt);
let propList = { };
for (let prop in aObject) {
propList[prop] = {
enumerable: true,
configurable: true,
writable: true,
value: this.wrap(aObject[prop], aCtxt)
}
}
Object.defineProperties(res, propList);
Cu.makeObjectPropsNormal(res);
return res;
dump("-*- ObjectWrapper is deprecated. Use Components.utils.cloneInto() instead.\n");
return Cu.cloneInto(aObject, aCtxt, { cloneFunctions: true });
}
}