зеркало из https://github.com/mozilla/gecko-dev.git
Bug 713965 - Replace deleteGeneric (taking a jsid) with deleteByValue (taking a Value), and use the property-type-specific methods exclusively. r=bhackett
--HG-- extra : rebase_source : c9273f81996c755f6b3814895a4ce64f390f7c50
This commit is contained in:
Родитель
558cd6384a
Коммит
dd39351d29
|
@ -4161,7 +4161,11 @@ JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, jsval *rval)
|
|||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
|
||||
return obj->deleteGeneric(cx, id, rval, false);
|
||||
|
||||
if (JSID_IS_SPECIAL(id))
|
||||
return obj->deleteSpecial(cx, JSID_TO_SPECIALID(id), rval, false);
|
||||
|
||||
return obj->deleteByValue(cx, IdToValue(id), rval, false);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
|
@ -4169,24 +4173,37 @@ JS_DeleteElement2(JSContext *cx, JSObject *obj, uint32_t index, jsval *rval)
|
|||
{
|
||||
AssertNoGC(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
jsid id;
|
||||
if (!IndexToId(cx, index, &id))
|
||||
return false;
|
||||
return JS_DeletePropertyById2(cx, obj, id, rval);
|
||||
assertSameCompartment(cx, obj);
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
|
||||
return obj->deleteElement(cx, index, rval, false);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name, jsval *rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
|
||||
|
||||
JSAtom *atom = js_Atomize(cx, name, strlen(name));
|
||||
return atom && JS_DeletePropertyById2(cx, obj, ATOM_TO_JSID(atom), rval);
|
||||
if (!atom)
|
||||
return false;
|
||||
|
||||
return obj->deleteByValue(cx, StringValue(atom), rval, false);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_DeleteUCProperty2(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, jsval *rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
|
||||
|
||||
JSAtom *atom = js_AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
|
||||
return atom && JS_DeletePropertyById2(cx, obj, ATOM_TO_JSID(atom), rval);
|
||||
if (!atom)
|
||||
return false;
|
||||
|
||||
return obj->deleteByValue(cx, StringValue(atom), rval, false);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
|
|
|
@ -522,9 +522,11 @@ static int
|
|||
DeleteArrayElement(JSContext *cx, JSObject *obj, jsdouble index, bool strict)
|
||||
{
|
||||
JS_ASSERT(index >= 0);
|
||||
JS_ASSERT(floor(index) == index);
|
||||
|
||||
if (obj->isDenseArray()) {
|
||||
if (index <= jsuint(-1)) {
|
||||
jsuint idx = jsuint(index);
|
||||
if (index <= UINT32_MAX) {
|
||||
uint32_t idx = uint32_t(index);
|
||||
if (idx < obj->getDenseArrayInitializedLength()) {
|
||||
obj->markDenseArrayNotPacked(cx);
|
||||
obj->setDenseArrayElement(idx, MagicValue(JS_ARRAY_HOLE));
|
||||
|
@ -535,16 +537,15 @@ DeleteArrayElement(JSContext *cx, JSObject *obj, jsdouble index, bool strict)
|
|||
return 1;
|
||||
}
|
||||
|
||||
AutoIdRooter idr(cx);
|
||||
|
||||
if (!IndexToId(cx, obj, index, NULL, idr.addr()))
|
||||
return -1;
|
||||
if (JSID_IS_VOID(idr.id()))
|
||||
return 1;
|
||||
|
||||
Value v;
|
||||
if (!obj->deleteGeneric(cx, idr.id(), &v, strict))
|
||||
return -1;
|
||||
if (index <= UINT32_MAX) {
|
||||
if (!obj->deleteElement(cx, uint32_t(index), &v, strict))
|
||||
return -1;
|
||||
} else {
|
||||
if (!obj->deleteByValue(cx, DoubleValue(index), &v, strict))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return v.isTrue() ? 1 : 0;
|
||||
}
|
||||
|
||||
|
@ -1140,36 +1141,20 @@ array_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *a
|
|||
}
|
||||
|
||||
static JSBool
|
||||
array_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
|
||||
array_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
if (!obj->isDenseArray())
|
||||
return js_DeleteProperty(cx, obj, id, rval, strict);
|
||||
return js_DeleteProperty(cx, obj, name, rval, strict);
|
||||
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
if (name == cx->runtime->atomState.lengthAtom) {
|
||||
rval->setBoolean(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (js_IdIsIndex(id, &i) && i < obj->getDenseArrayInitializedLength()) {
|
||||
obj->markDenseArrayNotPacked(cx);
|
||||
obj->setDenseArrayElement(i, MagicValue(JS_ARRAY_HOLE));
|
||||
}
|
||||
|
||||
if (!js_SuppressDeletedProperty(cx, obj, id))
|
||||
return false;
|
||||
|
||||
rval->setBoolean(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
array_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
|
||||
{
|
||||
return array_deleteGeneric(cx, obj, ATOM_TO_JSID(name), rval, strict);
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
||||
/* non-static for direct deletion of array elements within the engine */
|
||||
|
@ -1196,7 +1181,11 @@ array_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, J
|
|||
static JSBool
|
||||
array_deleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict)
|
||||
{
|
||||
return array_deleteGeneric(cx, obj, SPECIALID_TO_JSID(sid), rval, strict);
|
||||
if (!obj->isDenseArray())
|
||||
return js_DeleteSpecial(cx, obj, sid, rval, strict);
|
||||
|
||||
rval->setBoolean(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1271,7 +1260,6 @@ Class js::ArrayClass = {
|
|||
array_setPropertyAttributes,
|
||||
array_setElementAttributes,
|
||||
array_setSpecialAttributes,
|
||||
array_deleteGeneric,
|
||||
array_deleteProperty,
|
||||
array_deleteElement,
|
||||
array_deleteSpecial,
|
||||
|
|
|
@ -228,9 +228,7 @@ typedef JSBool
|
|||
typedef JSBool
|
||||
(* SpecialAttributesOp)(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp);
|
||||
typedef JSBool
|
||||
(* DeleteGenericOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict);
|
||||
typedef JSBool
|
||||
(* DeleteIdOp)(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict);
|
||||
(* DeletePropertyOp)(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict);
|
||||
typedef JSBool
|
||||
(* DeleteElementOp)(JSContext *cx, JSObject *obj, uint32_t index, Value *vp, JSBool strict);
|
||||
typedef JSBool
|
||||
|
@ -329,8 +327,7 @@ struct ObjectOps
|
|||
PropertyAttributesOp setPropertyAttributes;
|
||||
ElementAttributesOp setElementAttributes;
|
||||
SpecialAttributesOp setSpecialAttributes;
|
||||
DeleteGenericOp deleteGeneric;
|
||||
DeleteIdOp deleteProperty;
|
||||
DeletePropertyOp deleteProperty;
|
||||
DeleteElementOp deleteElement;
|
||||
DeleteSpecialOp deleteSpecial;
|
||||
|
||||
|
@ -343,7 +340,7 @@ struct ObjectOps
|
|||
|
||||
#define JS_NULL_OBJECT_OPS \
|
||||
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, \
|
||||
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, \
|
||||
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, \
|
||||
NULL,NULL,NULL,NULL,NULL,NULL}
|
||||
|
||||
struct Class
|
||||
|
|
|
@ -331,7 +331,7 @@ ArgSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value *vp)
|
|||
* that has a setter for this id.
|
||||
*/
|
||||
AutoValueRooter tvr(cx);
|
||||
return js_DeleteProperty(cx, &argsobj, id, tvr.addr(), false) &&
|
||||
return js_DeleteGeneric(cx, &argsobj, id, tvr.addr(), false) &&
|
||||
js_DefineProperty(cx, &argsobj, id, vp, NULL, NULL, JSPROP_ENUMERATE);
|
||||
}
|
||||
|
||||
|
@ -446,7 +446,7 @@ StrictArgSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value *vp)
|
|||
* collect its value.
|
||||
*/
|
||||
AutoValueRooter tvr(cx);
|
||||
return js_DeleteProperty(cx, &argsobj, id, tvr.addr(), strict) &&
|
||||
return js_DeleteGeneric(cx, &argsobj, id, tvr.addr(), strict) &&
|
||||
js_SetPropertyHelper(cx, &argsobj, id, 0, vp, strict);
|
||||
}
|
||||
|
||||
|
@ -1036,7 +1036,7 @@ StackFrame::getValidCalleeObject(JSContext *cx, Value *vp)
|
|||
* barrier, so we must clone fun and store it in fp's callee to
|
||||
* avoid re-cloning upon repeated foo.caller access.
|
||||
*
|
||||
* This must mean the code in js_DeleteProperty could not find this
|
||||
* This must mean the code in js_DeleteGeneric could not find this
|
||||
* stack frame on the stack when the method was deleted. We've lost
|
||||
* track of the method, so we associate it with the first barriered
|
||||
* object found starting from thisp on the prototype chain.
|
||||
|
|
|
@ -2769,12 +2769,10 @@ BEGIN_CASE(JSOP_DELELEM)
|
|||
JSObject *obj;
|
||||
FETCH_OBJECT(cx, -2, obj);
|
||||
|
||||
/* Fetch index and convert it to id suitable for use with obj. */
|
||||
jsid id;
|
||||
FETCH_ELEMENT_ID(obj, -1, id);
|
||||
const Value &propval = regs.sp[-1];
|
||||
Value &rval = regs.sp[-2];
|
||||
|
||||
/* Get or set the element. */
|
||||
if (!obj->deleteGeneric(cx, id, ®s.sp[-2], script->strictModeCode))
|
||||
if (!obj->deleteByValue(cx, propval, &rval, script->strictModeCode))
|
||||
goto error;
|
||||
|
||||
regs.sp--;
|
||||
|
|
|
@ -134,13 +134,13 @@ js_ValueToIterator(JSContext *cx, uintN flags, js::Value *vp);
|
|||
extern JS_FRIEND_API(JSBool)
|
||||
js_CloseIterator(JSContext *cx, JSObject *iterObj);
|
||||
|
||||
bool
|
||||
extern bool
|
||||
js_SuppressDeletedProperty(JSContext *cx, JSObject *obj, jsid id);
|
||||
|
||||
bool
|
||||
extern bool
|
||||
js_SuppressDeletedElement(JSContext *cx, JSObject *obj, uint32_t index);
|
||||
|
||||
bool
|
||||
extern bool
|
||||
js_SuppressDeletedElements(JSContext *cx, JSObject *obj, uint32_t begin, uint32_t end);
|
||||
|
||||
/*
|
||||
|
|
|
@ -3347,6 +3347,28 @@ JSObject::nonNativeSetElement(JSContext *cx, uint32_t index, js::Value *vp, JSBo
|
|||
return getOps()->setElement(cx, this, index, vp, strict);
|
||||
}
|
||||
|
||||
bool
|
||||
JSObject::deleteByValue(JSContext *cx, const Value &property, Value *rval, bool strict)
|
||||
{
|
||||
uint32_t index;
|
||||
if (IsDefinitelyIndex(property, &index))
|
||||
return deleteElement(cx, index, rval, strict);
|
||||
|
||||
Value propval = property;
|
||||
SpecialId sid;
|
||||
if (ValueIsSpecial(this, &propval, &sid, cx))
|
||||
return deleteSpecial(cx, sid, rval, strict);
|
||||
|
||||
JSAtom *name;
|
||||
if (!js_ValueToAtom(cx, propval, &name))
|
||||
return false;
|
||||
|
||||
if (name->isIndex(&index))
|
||||
return deleteElement(cx, index, rval, false);
|
||||
|
||||
return deleteProperty(cx, name->asPropertyName(), rval, false);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS_CopyPropertiesFrom(JSContext *cx, JSObject *target, JSObject *obj)
|
||||
{
|
||||
|
@ -3915,7 +3937,7 @@ DefineConstructorAndPrototype(JSContext *cx, HandleObject obj, JSProtoKey key, H
|
|||
bad:
|
||||
if (named) {
|
||||
Value rval;
|
||||
obj->deleteGeneric(cx, ATOM_TO_JSID(atom), &rval, false);
|
||||
obj->deleteByValue(cx, StringValue(atom), &rval, false);
|
||||
}
|
||||
if (cached)
|
||||
ClearClassObject(cx, obj, key);
|
||||
|
@ -5903,7 +5925,7 @@ js_SetElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, uintN *att
|
|||
}
|
||||
|
||||
JSBool
|
||||
js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
|
||||
js_DeleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
|
||||
{
|
||||
JSObject *proto;
|
||||
JSProperty *prop;
|
||||
|
@ -5974,13 +5996,25 @@ js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str
|
|||
return obj->removeProperty(cx, id) && js_SuppressDeletedProperty(cx, obj, id);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_DeleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
|
||||
{
|
||||
return js_DeleteGeneric(cx, obj, ATOM_TO_JSID(name), rval, strict);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_DeleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, JSBool strict)
|
||||
{
|
||||
jsid id;
|
||||
if (!IndexToId(cx, index, &id))
|
||||
return false;
|
||||
return js_DeleteProperty(cx, obj, id, rval, strict);
|
||||
return js_DeleteGeneric(cx, obj, id, rval, strict);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_DeleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict)
|
||||
{
|
||||
return js_DeleteGeneric(cx, obj, SPECIALID_TO_JSID(sid), rval, strict);
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
|
|
@ -327,11 +327,17 @@ extern JSBool
|
|||
js_SetElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, uintN *attrsp);
|
||||
|
||||
extern JSBool
|
||||
js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *rval, JSBool strict);
|
||||
js_DeleteProperty(JSContext *cx, JSObject *obj, js::PropertyName *name, js::Value *rval, JSBool strict);
|
||||
|
||||
extern JSBool
|
||||
js_DeleteElement(JSContext *cx, JSObject *obj, uint32_t index, js::Value *rval, JSBool strict);
|
||||
|
||||
extern JSBool
|
||||
js_DeleteSpecial(JSContext *cx, JSObject *obj, js::SpecialId sid, js::Value *rval, JSBool strict);
|
||||
|
||||
extern JSBool
|
||||
js_DeleteGeneric(JSContext *cx, JSObject *obj, jsid id, js::Value *rval, JSBool strict);
|
||||
|
||||
extern JSType
|
||||
js_TypeOf(JSContext *cx, JSObject *obj);
|
||||
|
||||
|
@ -1336,10 +1342,10 @@ struct JSObject : js::gc::Cell
|
|||
inline JSBool setElementAttributes(JSContext *cx, uint32_t index, uintN *attrsp);
|
||||
inline JSBool setSpecialAttributes(JSContext *cx, js::SpecialId sid, uintN *attrsp);
|
||||
|
||||
inline JSBool deleteGeneric(JSContext *cx, jsid id, js::Value *rval, JSBool strict);
|
||||
inline JSBool deleteProperty(JSContext *cx, js::PropertyName *name, js::Value *rval, JSBool strict);
|
||||
inline JSBool deleteElement(JSContext *cx, uint32_t index, js::Value *rval, JSBool strict);
|
||||
inline JSBool deleteSpecial(JSContext *cx, js::SpecialId sid, js::Value *rval, JSBool strict);
|
||||
inline bool deleteProperty(JSContext *cx, js::PropertyName *name, js::Value *rval, bool strict);
|
||||
inline bool deleteElement(JSContext *cx, uint32_t index, js::Value *rval, bool strict);
|
||||
inline bool deleteSpecial(JSContext *cx, js::SpecialId sid, js::Value *rval, bool strict);
|
||||
bool deleteByValue(JSContext *cx, const js::Value &property, js::Value *rval, bool strict);
|
||||
|
||||
inline bool enumerate(JSContext *cx, JSIterateOp iterop, js::Value *statep, jsid *idp);
|
||||
inline bool defaultValue(JSContext *cx, JSType hint, js::Value *vp);
|
||||
|
|
|
@ -229,35 +229,36 @@ JSObject::getProperty(JSContext *cx, js::PropertyName *name, js::Value *vp)
|
|||
return getGeneric(cx, ATOM_TO_JSID(name), vp);
|
||||
}
|
||||
|
||||
inline JSBool
|
||||
JSObject::deleteGeneric(JSContext *cx, jsid id, js::Value *rval, JSBool strict)
|
||||
inline bool
|
||||
JSObject::deleteProperty(JSContext *cx, js::PropertyName *name, js::Value *rval, bool strict)
|
||||
{
|
||||
js::types::AddTypePropertyId(cx, this, id,
|
||||
js::types::Type::UndefinedType());
|
||||
jsid id = js_CheckForStringIndex(ATOM_TO_JSID(name));
|
||||
js::types::AddTypePropertyId(cx, this, id, js::types::Type::UndefinedType());
|
||||
js::types::MarkTypePropertyConfigured(cx, this, id);
|
||||
js::DeleteGenericOp op = getOps()->deleteGeneric;
|
||||
return (op ? op : js_DeleteProperty)(cx, this, id, rval, strict);
|
||||
js::DeletePropertyOp op = getOps()->deleteProperty;
|
||||
return (op ? op : js_DeleteProperty)(cx, this, name, rval, strict);
|
||||
}
|
||||
|
||||
inline JSBool
|
||||
JSObject::deleteProperty(JSContext *cx, js::PropertyName *name, js::Value *rval, JSBool strict)
|
||||
{
|
||||
return deleteGeneric(cx, ATOM_TO_JSID(name), rval, strict);
|
||||
}
|
||||
|
||||
inline JSBool
|
||||
JSObject::deleteElement(JSContext *cx, uint32_t index, js::Value *rval, JSBool strict)
|
||||
inline bool
|
||||
JSObject::deleteElement(JSContext *cx, uint32_t index, js::Value *rval, bool strict)
|
||||
{
|
||||
jsid id;
|
||||
if (!js::IndexToId(cx, index, &id))
|
||||
return false;
|
||||
return deleteGeneric(cx, id, rval, strict);
|
||||
js::types::AddTypePropertyId(cx, this, id, js::types::Type::UndefinedType());
|
||||
js::types::MarkTypePropertyConfigured(cx, this, id);
|
||||
js::DeleteElementOp op = getOps()->deleteElement;
|
||||
return (op ? op : js_DeleteElement)(cx, this, index, rval, strict);
|
||||
}
|
||||
|
||||
inline JSBool
|
||||
JSObject::deleteSpecial(JSContext *cx, js::SpecialId sid, js::Value *rval, JSBool strict)
|
||||
inline bool
|
||||
JSObject::deleteSpecial(JSContext *cx, js::SpecialId sid, js::Value *rval, bool strict)
|
||||
{
|
||||
return deleteGeneric(cx, SPECIALID_TO_JSID(sid), rval, strict);
|
||||
jsid id = SPECIALID_TO_JSID(sid);
|
||||
js::types::AddTypePropertyId(cx, this, id, js::types::Type::UndefinedType());
|
||||
js::types::MarkTypePropertyConfigured(cx, this, id);
|
||||
js::DeleteSpecialOp op = getOps()->deleteSpecial;
|
||||
return (op ? op : js_DeleteSpecial)(cx, this, sid, rval, strict);
|
||||
}
|
||||
|
||||
inline void
|
||||
|
|
|
@ -839,7 +839,7 @@ Walk(JSContext *cx, JSObject *holder, jsid name, const Value &reviver, Value *vp
|
|||
|
||||
if (newElement.isUndefined()) {
|
||||
/* Step 2b(ii)(2). */
|
||||
if (!js_DeleteProperty(cx, obj, id, &newElement, false))
|
||||
if (!obj->deleteByValue(cx, IdToValue(id), &newElement, false))
|
||||
return false;
|
||||
} else {
|
||||
/* Step 2b(ii)(3). */
|
||||
|
|
|
@ -1166,7 +1166,7 @@ proxy_SetSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *a
|
|||
static JSBool
|
||||
proxy_DeleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
|
||||
{
|
||||
id = js_CheckForStringIndex(id);
|
||||
JS_ASSERT(id == js_CheckForStringIndex(id));
|
||||
|
||||
// TODO: throwing away strict
|
||||
bool deleted;
|
||||
|
@ -1179,7 +1179,7 @@ proxy_DeleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool s
|
|||
static JSBool
|
||||
proxy_DeleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
|
||||
{
|
||||
return proxy_DeleteGeneric(cx, obj, ATOM_TO_JSID(name), rval, strict);
|
||||
return proxy_DeleteGeneric(cx, obj, js_CheckForStringIndex(ATOM_TO_JSID(name)), rval, strict);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -1309,7 +1309,6 @@ JS_FRIEND_DATA(Class) js::ObjectProxyClass = {
|
|||
proxy_SetPropertyAttributes,
|
||||
proxy_SetElementAttributes,
|
||||
proxy_SetSpecialAttributes,
|
||||
proxy_DeleteGeneric,
|
||||
proxy_DeleteProperty,
|
||||
proxy_DeleteElement,
|
||||
proxy_DeleteSpecial,
|
||||
|
@ -1371,7 +1370,6 @@ JS_FRIEND_DATA(Class) js::OuterWindowProxyClass = {
|
|||
proxy_SetPropertyAttributes,
|
||||
proxy_SetElementAttributes,
|
||||
proxy_SetSpecialAttributes,
|
||||
proxy_DeleteGeneric,
|
||||
proxy_DeleteProperty,
|
||||
proxy_DeleteElement,
|
||||
proxy_DeleteSpecial,
|
||||
|
@ -1445,7 +1443,6 @@ JS_FRIEND_DATA(Class) js::FunctionProxyClass = {
|
|||
proxy_SetPropertyAttributes,
|
||||
proxy_SetElementAttributes,
|
||||
proxy_SetSpecialAttributes,
|
||||
proxy_DeleteGeneric,
|
||||
proxy_DeleteProperty,
|
||||
proxy_DeleteElement,
|
||||
proxy_DeleteSpecial,
|
||||
|
|
|
@ -582,9 +582,9 @@ ArrayBuffer::obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId si
|
|||
}
|
||||
|
||||
JSBool
|
||||
ArrayBuffer::obj_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
|
||||
ArrayBuffer::obj_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
|
||||
{
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
|
||||
if (name == cx->runtime->atomState.byteLengthAtom) {
|
||||
rval->setBoolean(false);
|
||||
return true;
|
||||
}
|
||||
|
@ -592,13 +592,7 @@ ArrayBuffer::obj_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rva
|
|||
JSObject *delegate = DelegateObject(cx, obj);
|
||||
if (!delegate)
|
||||
return false;
|
||||
return js_DeleteProperty(cx, delegate, id, rval, strict);
|
||||
}
|
||||
|
||||
JSBool
|
||||
ArrayBuffer::obj_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
|
||||
{
|
||||
return obj_deleteGeneric(cx, obj, ATOM_TO_JSID(name), rval, strict);
|
||||
return js_DeleteProperty(cx, delegate, name, rval, strict);
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
@ -613,7 +607,10 @@ ArrayBuffer::obj_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Val
|
|||
JSBool
|
||||
ArrayBuffer::obj_deleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict)
|
||||
{
|
||||
return obj_deleteGeneric(cx, obj, SPECIALID_TO_JSID(sid), rval, strict);
|
||||
JSObject *delegate = DelegateObject(cx, obj);
|
||||
if (!delegate)
|
||||
return false;
|
||||
return js_DeleteSpecial(cx, delegate, sid, rval, strict);
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
@ -1261,17 +1258,9 @@ class TypedArrayTemplate
|
|||
}
|
||||
|
||||
static JSBool
|
||||
obj_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
|
||||
obj_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
|
||||
{
|
||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||
rval->setBoolean(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject *tarray = TypedArray::getTypedArray(obj);
|
||||
JS_ASSERT(tarray);
|
||||
|
||||
if (isArrayIndex(cx, tarray, id)) {
|
||||
if (name == cx->runtime->atomState.lengthAtom) {
|
||||
rval->setBoolean(false);
|
||||
return true;
|
||||
}
|
||||
|
@ -1280,12 +1269,6 @@ class TypedArrayTemplate
|
|||
return true;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
obj_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
|
||||
{
|
||||
return obj_deleteGeneric(cx, obj, ATOM_TO_JSID(name), rval, strict);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
obj_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, JSBool strict)
|
||||
{
|
||||
|
@ -1304,7 +1287,8 @@ class TypedArrayTemplate
|
|||
static JSBool
|
||||
obj_deleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict)
|
||||
{
|
||||
return obj_deleteGeneric(cx, obj, SPECIALID_TO_JSID(sid), rval, strict);
|
||||
rval->setBoolean(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -2172,7 +2156,6 @@ Class js::ArrayBufferClass = {
|
|||
ArrayBuffer::obj_setPropertyAttributes,
|
||||
ArrayBuffer::obj_setElementAttributes,
|
||||
ArrayBuffer::obj_setSpecialAttributes,
|
||||
ArrayBuffer::obj_deleteGeneric,
|
||||
ArrayBuffer::obj_deleteProperty,
|
||||
ArrayBuffer::obj_deleteElement,
|
||||
ArrayBuffer::obj_deleteSpecial,
|
||||
|
@ -2285,7 +2268,6 @@ JSFunctionSpec _typedArray::jsfuncs[] = { \
|
|||
_typedArray::obj_setPropertyAttributes, \
|
||||
_typedArray::obj_setElementAttributes, \
|
||||
_typedArray::obj_setSpecialAttributes, \
|
||||
_typedArray::obj_deleteGeneric, \
|
||||
_typedArray::obj_deleteProperty, \
|
||||
_typedArray::obj_deleteElement, \
|
||||
_typedArray::obj_deleteSpecial, \
|
||||
|
|
|
@ -145,8 +145,6 @@ struct JS_FRIEND_API(ArrayBuffer) {
|
|||
static JSBool
|
||||
obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp);
|
||||
|
||||
static JSBool
|
||||
obj_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict);
|
||||
static JSBool
|
||||
obj_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict);
|
||||
static JSBool
|
||||
|
|
|
@ -4990,14 +4990,12 @@ xml_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *att
|
|||
static JSBool
|
||||
xml_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
|
||||
{
|
||||
JSXML *xml;
|
||||
jsval idval;
|
||||
uint32_t index;
|
||||
JSObject *nameqn;
|
||||
jsid funid;
|
||||
|
||||
idval = IdToJsval(id);
|
||||
xml = (JSXML *) obj->getPrivate();
|
||||
Value idval = IdToValue(id);
|
||||
JSXML *xml = (JSXML *) obj->getPrivate();
|
||||
if (js_IdIsIndex(id, &index)) {
|
||||
if (xml->xml_class != JSXML_CLASS_LIST) {
|
||||
/* See NOTE in spec: this variation is reserved for future use. */
|
||||
|
@ -5012,7 +5010,7 @@ xml_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str
|
|||
if (!nameqn)
|
||||
return false;
|
||||
if (!JSID_IS_VOID(funid))
|
||||
return js_DeleteProperty(cx, obj, funid, rval, false);
|
||||
return js_DeleteGeneric(cx, obj, funid, rval, false);
|
||||
|
||||
DeleteNamedProperty(cx, xml, nameqn,
|
||||
nameqn->getClass() == &AttributeNameClass);
|
||||
|
@ -5025,7 +5023,7 @@ xml_deleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str
|
|||
* property's getter or setter. But now it's time to remove any such
|
||||
* property, to purge the property cache and remove the scope entry.
|
||||
*/
|
||||
if (!obj->nativeEmpty() && !js_DeleteProperty(cx, obj, id, rval, false))
|
||||
if (!obj->nativeEmpty() && !js_DeleteGeneric(cx, obj, id, rval, false))
|
||||
return false;
|
||||
|
||||
rval->setBoolean(true);
|
||||
|
@ -5398,7 +5396,6 @@ JS_FRIEND_DATA(Class) js::XMLClass = {
|
|||
xml_setPropertyAttributes,
|
||||
xml_setElementAttributes,
|
||||
xml_setSpecialAttributes,
|
||||
xml_deleteGeneric,
|
||||
xml_deleteProperty,
|
||||
xml_deleteElement,
|
||||
xml_deleteSpecial,
|
||||
|
|
|
@ -2052,11 +2052,10 @@ stubs::DelElem(VMFrame &f)
|
|||
if (!obj)
|
||||
THROW();
|
||||
|
||||
jsid id;
|
||||
if (!FetchElementId(f, obj, f.regs.sp[-1], id, &f.regs.sp[-1]))
|
||||
THROW();
|
||||
const Value &propval = f.regs.sp[-1];
|
||||
Value &rval = f.regs.sp[-2];
|
||||
|
||||
if (!obj->deleteGeneric(cx, id, &f.regs.sp[-2], strict))
|
||||
if (!obj->deleteByValue(cx, propval, &rval, strict))
|
||||
THROW();
|
||||
}
|
||||
|
||||
|
|
|
@ -3364,17 +3364,14 @@ static JSBool
|
|||
DebuggerObject_deleteProperty(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, "deleteProperty", args, dbg, obj);
|
||||
Value arg = argc > 0 ? args[0] : UndefinedValue();
|
||||
jsid id;
|
||||
if (!ValueToId(cx, arg, &id))
|
||||
return false;
|
||||
Value nameArg = argc > 0 ? args[0] : UndefinedValue();
|
||||
|
||||
AutoCompartment ac(cx, obj);
|
||||
if (!ac.enter() || !cx->compartment->wrapId(cx, &id))
|
||||
if (!ac.enter() || !cx->compartment->wrap(cx, &nameArg))
|
||||
return false;
|
||||
|
||||
ErrorCopier ec(ac, dbg->toJSObject());
|
||||
return obj->deleteGeneric(cx, id, &args.rval(), false);
|
||||
return obj->deleteByValue(cx, nameArg, &args.rval(), false);
|
||||
}
|
||||
|
||||
enum SealHelperOp { Seal, Freeze, PreventExtensions };
|
||||
|
|
|
@ -331,12 +331,6 @@ with_SetSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *at
|
|||
return obj->asWith().object().setSpecialAttributes(cx, sid, attrsp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
with_DeleteGeneric(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
|
||||
{
|
||||
return obj->asWith().object().deleteGeneric(cx, id, rval, strict);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
with_DeleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict)
|
||||
{
|
||||
|
@ -421,7 +415,6 @@ Class js::WithClass = {
|
|||
with_SetPropertyAttributes,
|
||||
with_SetElementAttributes,
|
||||
with_SetSpecialAttributes,
|
||||
with_DeleteGeneric,
|
||||
with_DeleteProperty,
|
||||
with_DeleteElement,
|
||||
with_DeleteSpecial,
|
||||
|
|
|
@ -876,7 +876,6 @@ js::Class XPC_WN_NoHelper_JSClass = {
|
|||
nsnull, // setAttributes
|
||||
nsnull, // setElementAttributes
|
||||
nsnull, // setSpecialAttributes
|
||||
nsnull, // deleteGeneric
|
||||
nsnull, // deleteProperty
|
||||
nsnull, // deleteElement
|
||||
nsnull, // deleteSpecial
|
||||
|
|
|
@ -1415,7 +1415,6 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JSObject *obj);
|
|||
nsnull, /* setAttributes */ \
|
||||
nsnull, /* setElementAttributes */ \
|
||||
nsnull, /* setSpecialAttributes */ \
|
||||
nsnull, /* deleteGeneric */ \
|
||||
nsnull, /* deleteProperty */ \
|
||||
nsnull, /* deleteElement */ \
|
||||
nsnull, /* deleteSpecial */ \
|
||||
|
@ -1453,7 +1452,6 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JSObject *obj);
|
|||
nsnull, /* setAttributes */ \
|
||||
nsnull, /* setElementAttributes */ \
|
||||
nsnull, /* setSpecialAttributes */ \
|
||||
nsnull, /* deleteGeneric */ \
|
||||
nsnull, /* deleteProperty */ \
|
||||
nsnull, /* deleteElement */ \
|
||||
nsnull, /* deleteSpecial */ \
|
||||
|
|
Загрузка…
Ссылка в новой задаче