Bug 1125624, part 3 - Remove js::StandardDefineProperty and js::DefineOwnProperty. r=Waldo.

--HG--
extra : rebase_source : afcc8c4461b1ea744e2beea948370c3c20ff70af
extra : source : 94f14d6b26d5e6c060e965c0982708e63d27db66
This commit is contained in:
Jason Orendorff 2015-05-29 16:48:26 -05:00
Родитель cc139ad82a
Коммит 461581c95f
13 изменённых файлов: 31 добавлений и 78 удалений

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

@ -181,12 +181,12 @@ DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::
return result.succeed();
}
JSObject* expando = EnsureExpandoObject(cx, proxy);
JS::Rooted<JSObject*> expando(cx, EnsureExpandoObject(cx, proxy));
if (!expando) {
return false;
}
if (!js::DefineOwnProperty(cx, expando, id, desc, result)) {
if (!JS_DefinePropertyById(cx, expando, id, desc, result)) {
return false;
}
*defined = true;

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

@ -189,7 +189,7 @@ WrapperAnswer::RecvDefineProperty(const ObjectId& objId, const JSIDVariant& idVa
return fail(jsapi, rs);
ObjectOpResult success;
if (!js::DefineOwnProperty(cx, obj, id, desc, success))
if (!JS_DefinePropertyById(cx, obj, id, desc, success))
return fail(jsapi, rs);
return ok(rs, success);
}

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

@ -832,7 +832,7 @@ js::obj_defineProperty(JSContext* cx, unsigned argc, Value* vp)
return false;
// Steps 6-8.
if (!StandardDefineProperty(cx, obj, id, desc))
if (!DefineProperty(cx, obj, id, desc))
return false;
args.rval().setObject(*obj);
return true;

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

@ -1200,23 +1200,6 @@ js::GetObjectMetadata(JSObject* obj)
return nullptr;
}
JS_FRIEND_API(bool)
js::DefineOwnProperty(JSContext* cx, JSObject* objArg, jsid idArg,
JS::Handle<js::PropertyDescriptor> descriptor, ObjectOpResult& result)
{
RootedObject obj(cx, objArg);
RootedId id(cx, idArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id, descriptor.value());
if (descriptor.hasGetterObject())
assertSameCompartment(cx, descriptor.getterObject());
if (descriptor.hasSetterObject())
assertSameCompartment(cx, descriptor.setterObject());
return StandardDefineProperty(cx, obj, id, descriptor, result);
}
JS_FRIEND_API(bool)
js::ReportIsNotFunction(JSContext* cx, HandleValue v)
{

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

@ -2813,10 +2813,6 @@ GetFirstSubsumedSavedFrame(JSContext* cx, JS::HandleObject savedFrame);
extern JS_FRIEND_API(bool)
ReportIsNotFunction(JSContext* cx, JS::HandleValue v);
extern JS_FRIEND_API(bool)
DefineOwnProperty(JSContext* cx, JSObject* objArg, jsid idArg,
JS::Handle<JSPropertyDescriptor> descriptor, JS::ObjectOpResult& result);
extern JS_FRIEND_API(JSObject*)
ConvertArgsToArray(JSContext* cx, const JS::CallArgs& args);

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

@ -274,23 +274,7 @@ js::Throw(JSContext* cx, JSObject* obj, unsigned errorNumber)
}
/*** Standard-compliant property definition (used by Object.defineProperty) **********************/
bool
js::StandardDefineProperty(JSContext* cx, HandleObject obj, HandleId id,
Handle<PropertyDescriptor> desc, ObjectOpResult& result)
{
return DefineProperty(cx, obj, id, desc, result);
}
bool
js::StandardDefineProperty(JSContext* cx, HandleObject obj, HandleId id,
Handle<PropertyDescriptor> desc)
{
ObjectOpResult success;
return DefineProperty(cx, obj, id, desc, success) &&
success.checkStrict(cx, obj, id);
}
/*** PropertyDescriptor operations and DefineProperties ******************************************/
bool
CheckCallable(JSContext* cx, JSObject* obj, const char* fieldName)
@ -487,13 +471,14 @@ js::DefineProperties(JSContext* cx, HandleObject obj, HandleObject props)
return false;
for (size_t i = 0, len = ids.length(); i < len; i++) {
if (!StandardDefineProperty(cx, obj, ids[i], descs[i]))
if (!DefineProperty(cx, obj, ids[i], descs[i]))
return false;
}
return true;
}
/*** Seal and freeze *****************************************************************************/
static unsigned
@ -596,15 +581,15 @@ js::SetIntegrityLevel(JSContext* cx, HandleObject obj, IntegrityLevel level)
}
// 8.a.i-ii. / 9.a.iii.3-4
if (!StandardDefineProperty(cx, obj, id, desc))
if (!DefineProperty(cx, obj, id, desc))
return false;
}
}
// Ordinarily ArraySetLength handles this, but we're going behind its back
// right now, so we must do this manually. Neither the custom property
// tree mutations nor the StandardDefineProperty call in the above code will
// do this for us.
// tree mutations nor the DefineProperty call in the above code will do
// this for us.
//
// ArraySetLength also implements the capacity <= length invariant for
// arrays with non-writable length. We don't need to do anything special
@ -1112,7 +1097,7 @@ JS_CopyPropertyFrom(JSContext* cx, HandleId id, HandleObject target,
if (!cx->compartment()->wrap(cx, &desc))
return false;
return StandardDefineProperty(cx, target, wrappedId, desc);
return DefineProperty(cx, target, wrappedId, desc);
}
JS_FRIEND_API(bool)
@ -2615,6 +2600,14 @@ js::GetOwnPropertyDescriptor(JSContext* cx, HandleObject obj, HandleId id,
return true;
}
bool
js::DefineProperty(JSContext* cx, HandleObject obj, HandleId id, Handle<PropertyDescriptor> desc)
{
ObjectOpResult result;
return DefineProperty(cx, obj, id, desc, result) &&
result.checkStrict(cx, obj, id);
}
bool
js::DefineProperty(JSContext* cx, HandleObject obj, HandleId id, Handle<PropertyDescriptor> desc,
ObjectOpResult& result)

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

@ -756,29 +756,7 @@ extern bool
GetOwnPropertyDescriptor(JSContext* cx, HandleObject obj, HandleId id,
MutableHandle<PropertyDescriptor> desc);
/*
* ES6 [[DefineOwnProperty]]. Define a property on obj.
*
* If obj is an array, this follows ES5 15.4.5.1.
* If obj is any other native object, this follows ES5 8.12.9.
* If obj is a proxy, this calls the proxy handler's defineProperty method.
* Otherwise, this reports an error and returns false.
*
* Both StandardDefineProperty functions hew close to the ES5 spec. Note that
* the DefineProperty functions do not enforce some invariants mandated by ES6.
*/
extern bool
StandardDefineProperty(JSContext* cx, HandleObject obj, HandleId id,
Handle<PropertyDescriptor> descriptor, ObjectOpResult& result);
/*
* Same as above except without the ObjectOpResult out-parameter. Throws a
* TypeError on failure.
*/
extern bool
StandardDefineProperty(JSContext* cx, HandleObject obj, HandleId id,
Handle<PropertyDescriptor> desc);
/* ES6 [[DefineOwnProperty]]. Define a property on obj. */
extern bool
DefineProperty(JSContext* cx, HandleObject obj, HandleId id,
Handle<PropertyDescriptor> desc, ObjectOpResult& result);
@ -799,6 +777,9 @@ DefineElement(ExclusiveContext* cx, HandleObject obj, uint32_t index, HandleValu
* When the 'result' out-param is omitted, the behavior is the same as above, except
* that any failure results in a TypeError.
*/
extern bool
DefineProperty(JSContext* cx, HandleObject obj, HandleId id, Handle<PropertyDescriptor> desc);
extern bool
DefineProperty(ExclusiveContext* cx, HandleObject obj, HandleId id, HandleValue value,
JSGetterOp getter = nullptr,

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

@ -719,7 +719,7 @@ Walk(JSContext* cx, HandleObject holder, HandleId name, HandleValue reviver, Mut
/* Step 2a(iii)(3). The spec deliberately ignores strict failure. */
Rooted<PropertyDescriptor> desc(cx);
desc.setDataDescriptor(newElement, JSPROP_ENUMERATE);
if (!StandardDefineProperty(cx, obj, id, desc, ignored))
if (!DefineProperty(cx, obj, id, desc, ignored))
return false;
}
}
@ -747,7 +747,7 @@ Walk(JSContext* cx, HandleObject holder, HandleId name, HandleValue reviver, Mut
/* Step 2b(ii)(3). The spec deliberately ignores strict failure. */
Rooted<PropertyDescriptor> desc(cx);
desc.setDataDescriptor(newElement, JSPROP_ENUMERATE);
if (!StandardDefineProperty(cx, obj, id, desc, ignored))
if (!DefineProperty(cx, obj, id, desc, ignored))
return false;
}
}

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

@ -39,7 +39,7 @@ DirectProxyHandler::defineProperty(JSContext* cx, HandleObject proxy, HandleId i
{
assertEnteredPolicy(cx, proxy, id, SET);
RootedObject target(cx, proxy->as<ProxyObject>().target());
return StandardDefineProperty(cx, target, id, desc, result);
return DefineProperty(cx, target, id, desc, result);
}
bool

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

@ -548,7 +548,7 @@ ScriptedDirectProxyHandler::defineProperty(JSContext* cx, HandleObject proxy, Ha
// step 8
if (trap.isUndefined())
return StandardDefineProperty(cx, target, id, desc, result);
return DefineProperty(cx, target, id, desc, result);
// step 9
RootedValue descObj(cx);

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

@ -7020,7 +7020,7 @@ DebuggerObject_defineProperty(JSContext* cx, unsigned argc, Value* vp)
return false;
ErrorCopier ec(ac);
if (!StandardDefineProperty(cx, obj, id, desc))
if (!DefineProperty(cx, obj, id, desc))
return false;
}
@ -7063,7 +7063,7 @@ DebuggerObject_defineProperties(JSContext* cx, unsigned argc, Value* vp)
ErrorCopier ec(ac);
for (size_t i = 0; i < n; i++) {
if (!StandardDefineProperty(cx, obj, ids[i], descs[i]))
if (!DefineProperty(cx, obj, ids[i], descs[i]))
return false;
}
}

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

@ -349,7 +349,7 @@ js::intrinsic_DefineDataProperty(JSContext* cx, unsigned argc, Value* vp)
Rooted<PropertyDescriptor> desc(cx);
desc.setDataDescriptor(value, attrs);
if (!StandardDefineProperty(cx, obj, id, desc))
if (!DefineProperty(cx, obj, id, desc))
return false;
args.rval().setUndefined();

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

@ -609,7 +609,7 @@ UnboxedPlainObject::convertToNative(JSContext* cx, JSObject* obj)
if (!GetOwnPropertyDescriptor(cx, nexpando, id, &desc))
return false;
ObjectOpResult result;
if (!StandardDefineProperty(cx, nobj, id, desc, result))
if (!DefineProperty(cx, nobj, id, desc, result))
return false;
MOZ_ASSERT(result.ok());
}