Bug 691992 - Split getAttributes and setAttributes into property and generic forms, and use them throughout the engine. r=bhackett

--HG--
extra : rebase_source : ab383bf621c212424db6c0f358b6dd2c31443b68
This commit is contained in:
Jeff Walden 2011-10-04 17:21:06 -07:00
parent 9f229b37a7
commit 3cd5da43d5
13 changed files with 229 additions and 112 deletions

View File

@ -3708,7 +3708,7 @@ GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, uintN flags,
? Proxy::getOwnPropertyDescriptor(cx, obj2, id, false, desc)
: Proxy::getPropertyDescriptor(cx, obj2, id, false, desc);
}
if (!obj2->getAttributes(cx, id, &desc->attrs))
if (!obj2->getGenericAttributes(cx, id, &desc->attrs))
return false;
desc->getter = NULL;
desc->setter = NULL;
@ -3802,7 +3802,7 @@ SetPropertyAttributesById(JSContext *cx, JSObject *obj, jsid id, uintN attrs, JS
}
JSBool ok = obj->isNative()
? js_SetNativeAttributes(cx, obj, (Shape *) prop, attrs)
: obj->setAttributes(cx, id, &attrs);
: obj->setGenericAttributes(cx, id, &attrs);
if (ok)
*foundp = true;
return ok;

View File

@ -1092,11 +1092,20 @@ array_defineSpecial(JSContext *cx, JSObject *obj, SpecialId sid, const Value *va
}
static JSBool
array_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
array_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
*attrsp = JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)
? JSPROP_PERMANENT : JSPROP_ENUMERATE;
return JS_TRUE;
return true;
}
static JSBool
array_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
*attrsp = (name == cx->runtime->atomState.lengthAtom)
? JSPROP_PERMANENT
: JSPROP_ENUMERATE;
return true;
}
static JSBool
@ -1109,11 +1118,19 @@ array_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *at
static JSBool
array_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return array_getAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
*attrsp = JSPROP_ENUMERATE;
return true;
}
static JSBool
array_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
array_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
static JSBool
array_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
@ -1129,7 +1146,8 @@ array_setElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *at
static JSBool
array_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return array_setAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
namespace js {
@ -1249,12 +1267,12 @@ Class js::ArrayClass = {
array_setProperty,
array_setElement,
array_setSpecial,
array_getAttributes,
array_getAttributes,
array_getGenericAttributes,
array_getPropertyAttributes,
array_getElementAttributes,
array_getSpecialAttributes,
array_setAttributes,
array_setAttributes,
array_setGenericAttributes,
array_setPropertyAttributes,
array_setElementAttributes,
array_setSpecialAttributes,
array_deleteProperty,

View File

@ -220,7 +220,7 @@ typedef JSBool
typedef JSBool
(* GenericAttributesOp)(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
typedef JSBool
(* AttributesOp)(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
(* PropertyAttributesOp)(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp);
typedef JSBool
(* ElementAttributesOp)(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp);
typedef JSBool
@ -319,11 +319,11 @@ struct ObjectOps
StrictElementIdOp setElement;
StrictSpecialIdOp setSpecial;
GenericAttributesOp getGenericAttributes;
AttributesOp getAttributes;
PropertyAttributesOp getPropertyAttributes;
ElementAttributesOp getElementAttributes;
SpecialAttributesOp getSpecialAttributes;
GenericAttributesOp setGenericAttributes;
AttributesOp setAttributes;
PropertyAttributesOp setPropertyAttributes;
ElementAttributesOp setElementAttributes;
SpecialAttributesOp setSpecialAttributes;
DeleteGenericOp deleteGeneric;

View File

@ -838,7 +838,7 @@ js::CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs)
if (obj2->isNative()) {
oldAttrs = ((Shape *) prop)->attributes();
} else {
if (!obj2->getAttributes(cx, id, &oldAttrs))
if (!obj2->getGenericAttributes(cx, id, &oldAttrs))
return false;
}

View File

@ -871,7 +871,7 @@ SuppressDeletedPropertyHelper(JSContext *cx, JSObject *obj, IdPredicate predicat
uintN attrs;
if (obj2.object()->isNative())
attrs = ((Shape *) prop)->attributes();
else if (!obj2.object()->getAttributes(cx, *idp, &attrs))
else if (!obj2.object()->getGenericAttributes(cx, *idp, &attrs))
return false;
if (attrs & JSPROP_ENUMERATE)

View File

@ -1595,7 +1595,7 @@ js_PropertyIsEnumerable(JSContext *cx, JSObject *obj, jsid id, Value *vp)
}
uintN attrs;
if (!pobj->getAttributes(cx, id, &attrs))
if (!pobj->getGenericAttributes(cx, id, &attrs))
return false;
vp->setBoolean((attrs & JSPROP_ENUMERATE) != 0);
@ -1863,7 +1863,7 @@ GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, PropertyDescript
desc->setter = CastAsStrictPropertyOp(shape->setterObject());
}
} else {
if (!pobj->getAttributes(cx, id, &desc->attrs))
if (!pobj->getGenericAttributes(cx, id, &desc->attrs))
return false;
}
@ -2750,7 +2750,7 @@ JSObject::sealOrFreeze(JSContext *cx, ImmutabilityType it)
jsid id = props[i];
uintN attrs;
if (!getAttributes(cx, id, &attrs))
if (!getGenericAttributes(cx, id, &attrs))
return false;
/* Make all attributes permanent; if freezing, make data attributes read-only. */
@ -2765,7 +2765,7 @@ JSObject::sealOrFreeze(JSContext *cx, ImmutabilityType it)
continue;
attrs |= new_attrs;
if (!setAttributes(cx, id, &attrs))
if (!setGenericAttributes(cx, id, &attrs))
return false;
}
@ -2788,7 +2788,7 @@ JSObject::isSealedOrFrozen(JSContext *cx, ImmutabilityType it, bool *resultp)
jsid id = props[i];
uintN attrs;
if (!getAttributes(cx, id, &attrs))
if (!getGenericAttributes(cx, id, &attrs))
return false;
/*
@ -3337,45 +3337,51 @@ with_SetSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool s
}
static JSBool
with_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
with_GetGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
return obj->getProto()->getAttributes(cx, id, attrsp);
return obj->getProto()->getGenericAttributes(cx, id, attrsp);
}
static JSBool
with_GetPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
return obj->getProto()->getPropertyAttributes(cx, name, attrsp);
}
static JSBool
with_GetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return with_GetAttributes(cx, obj, id, attrsp);
return obj->getProto()->getElementAttributes(cx, index, attrsp);
}
static JSBool
with_GetSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return with_GetAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return obj->getProto()->getSpecialAttributes(cx, sid, attrsp);
}
static JSBool
with_SetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
with_SetGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
return obj->getProto()->setAttributes(cx, id, attrsp);
return obj->getProto()->setGenericAttributes(cx, id, attrsp);
}
static JSBool
with_SetPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
return obj->getProto()->setPropertyAttributes(cx, name, attrsp);
}
static JSBool
with_SetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return with_SetAttributes(cx, obj, id, attrsp);
return obj->getProto()->setElementAttributes(cx, index, attrsp);
}
static JSBool
with_SetSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return with_SetAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return obj->getProto()->setSpecialAttributes(cx, sid, attrsp);
}
static JSBool
@ -3454,12 +3460,12 @@ Class js::WithClass = {
with_SetProperty,
with_SetElement,
with_SetSpecial,
with_GetAttributes,
with_GetAttributes,
with_GetGenericAttributes,
with_GetPropertyAttributes,
with_GetElementAttributes,
with_GetSpecialAttributes,
with_SetAttributes,
with_SetAttributes,
with_SetGenericAttributes,
with_SetPropertyAttributes,
with_SetElementAttributes,
with_SetSpecialAttributes,
with_DeleteProperty,
@ -6336,7 +6342,7 @@ js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
return true;
}
if (!obj->isNative())
return obj->getAttributes(cx, id, attrsp);
return obj->getGenericAttributes(cx, id, attrsp);
const Shape *shape = (Shape *)prop;
*attrsp = shape->attributes();
@ -6379,7 +6385,7 @@ js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
return true;
return obj->isNative()
? js_SetNativeAttributes(cx, obj, (Shape *) prop, *attrsp)
: obj->setAttributes(cx, id, attrsp);
: obj->setGenericAttributes(cx, id, attrsp);
}
JSBool

View File

@ -1401,22 +1401,15 @@ struct JSObject : js::gc::Cell {
JSBool nonNativeSetElement(JSContext *cx, uint32 index, js::Value *vp, JSBool strict);
JSBool getAttributes(JSContext *cx, jsid id, uintN *attrsp) {
js::AttributesOp op = getOps()->getAttributes;
return (op ? op : js_GetAttributes)(cx, this, id, attrsp);
}
inline JSBool getGenericAttributes(JSContext *cx, jsid id, uintN *attrsp);
inline JSBool getPropertyAttributes(JSContext *cx, js::PropertyName *name, uintN *attrsp);
inline JSBool getElementAttributes(JSContext *cx, uint32 index, uintN *attrsp);
inline JSBool getSpecialAttributes(JSContext *cx, js::SpecialId sid, uintN *attrsp);
JSBool getElementAttributes(JSContext *cx, uint32 index, uintN *attrsp) {
js::ElementAttributesOp op = getOps()->getElementAttributes;
return (op ? op : js_GetElementAttributes)(cx, this, index, attrsp);
}
inline JSBool setAttributes(JSContext *cx, jsid id, uintN *attrsp);
JSBool setElementAttributes(JSContext *cx, uint32 index, uintN *attrsp) {
js::ElementAttributesOp op = getOps()->setElementAttributes;
return (op ? op : js_SetElementAttributes)(cx, this, index, attrsp);
}
inline JSBool setGenericAttributes(JSContext *cx, jsid id, uintN *attrsp);
inline JSBool setPropertyAttributes(JSContext *cx, js::PropertyName *name, uintN *attrsp);
inline JSBool setElementAttributes(JSContext *cx, uint32 index, uintN *attrsp);
inline JSBool setSpecialAttributes(JSContext *cx, js::SpecialId sid, uintN *attrsp);
inline JSBool deleteProperty(JSContext *cx, jsid id, js::Value *rval, JSBool strict);

View File

@ -126,13 +126,32 @@ JSObject::unbrand(JSContext *cx)
}
inline JSBool
JSObject::setAttributes(JSContext *cx, jsid id, uintN *attrsp)
JSObject::setGenericAttributes(JSContext *cx, jsid id, uintN *attrsp)
{
js::types::MarkTypePropertyConfigured(cx, this, id);
js::AttributesOp op = getOps()->setAttributes;
js::GenericAttributesOp op = getOps()->setGenericAttributes;
return (op ? op : js_SetAttributes)(cx, this, id, attrsp);
}
inline JSBool
JSObject::setPropertyAttributes(JSContext *cx, js::PropertyName *name, uintN *attrsp)
{
return setGenericAttributes(cx, ATOM_TO_JSID(name), attrsp);
}
inline JSBool
JSObject::setElementAttributes(JSContext *cx, uint32 index, uintN *attrsp)
{
js::ElementAttributesOp op = getOps()->setElementAttributes;
return (op ? op : js_SetElementAttributes)(cx, this, index, attrsp);
}
inline JSBool
JSObject::setSpecialAttributes(JSContext *cx, js::SpecialId sid, uintN *attrsp)
{
return setGenericAttributes(cx, SPECIALID_TO_JSID(sid), attrsp);
}
inline JSBool
JSObject::getGeneric(JSContext *cx, JSObject *receiver, jsid id, js::Value *vp)
{
@ -1162,6 +1181,34 @@ JSObject::getSpecial(JSContext *cx, js::SpecialId sid, js::Value *vp)
return getGeneric(cx, SPECIALID_TO_JSID(sid), vp);
}
inline JSBool
JSObject::getGenericAttributes(JSContext *cx, jsid id, uintN *attrsp)
{
js::GenericAttributesOp op = getOps()->getGenericAttributes;
return (op ? op : js_GetAttributes)(cx, this, id, attrsp);
}
inline JSBool
JSObject::getPropertyAttributes(JSContext *cx, js::PropertyName *name, uintN *attrsp)
{
return getGenericAttributes(cx, ATOM_TO_JSID(name), attrsp);
}
inline JSBool
JSObject::getElementAttributes(JSContext *cx, uint32 index, uintN *attrsp)
{
jsid id;
if (!js::IndexToId(cx, index, &id))
return false;
return getGenericAttributes(cx, id, attrsp);
}
inline JSBool
JSObject::getSpecialAttributes(JSContext *cx, js::SpecialId sid, uintN *attrsp)
{
return getGenericAttributes(cx, SPECIALID_TO_JSID(sid), attrsp);
}
inline bool
JSObject::isProxy() const
{

View File

@ -1040,7 +1040,7 @@ proxy_SetSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool
}
static JSBool
proxy_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
proxy_GetGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
id = js_CheckForStringIndex(id);
@ -1051,23 +1051,29 @@ proxy_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
return true;
}
static JSBool
proxy_GetPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
return proxy_GetGenericAttributes(cx, obj, ATOM_TO_JSID(name), attrsp);
}
static JSBool
proxy_GetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return proxy_GetAttributes(cx, obj, id, attrsp);
return proxy_GetGenericAttributes(cx, obj, id, attrsp);
}
static JSBool
proxy_GetSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return proxy_GetAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return proxy_GetGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
}
static JSBool
proxy_SetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
proxy_SetGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
id = js_CheckForStringIndex(id);
@ -1079,19 +1085,25 @@ proxy_SetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
return Proxy::defineProperty(cx, obj, id, &desc);
}
static JSBool
proxy_SetPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
return proxy_SetGenericAttributes(cx, obj, ATOM_TO_JSID(name), attrsp);
}
static JSBool
proxy_SetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return proxy_SetAttributes(cx, obj, id, attrsp);
return proxy_SetGenericAttributes(cx, obj, id, attrsp);
}
static JSBool
proxy_SetSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return proxy_SetAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return proxy_SetGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
}
static JSBool
@ -1225,12 +1237,12 @@ JS_FRIEND_DATA(Class) js::ObjectProxyClass = {
proxy_SetProperty,
proxy_SetElement,
proxy_SetSpecial,
proxy_GetAttributes,
proxy_GetAttributes,
proxy_GetGenericAttributes,
proxy_GetPropertyAttributes,
proxy_GetElementAttributes,
proxy_GetSpecialAttributes,
proxy_SetAttributes,
proxy_SetAttributes,
proxy_SetGenericAttributes,
proxy_SetPropertyAttributes,
proxy_SetElementAttributes,
proxy_SetSpecialAttributes,
proxy_DeleteProperty,
@ -1286,12 +1298,12 @@ JS_FRIEND_DATA(Class) js::OuterWindowProxyClass = {
proxy_SetProperty,
proxy_SetElement,
proxy_SetSpecial,
proxy_GetAttributes,
proxy_GetAttributes,
proxy_GetGenericAttributes,
proxy_GetPropertyAttributes,
proxy_GetElementAttributes,
proxy_GetSpecialAttributes,
proxy_SetAttributes,
proxy_SetAttributes,
proxy_SetGenericAttributes,
proxy_SetPropertyAttributes,
proxy_SetElementAttributes,
proxy_SetSpecialAttributes,
proxy_DeleteProperty,
@ -1359,12 +1371,12 @@ JS_FRIEND_DATA(Class) js::FunctionProxyClass = {
proxy_SetProperty,
proxy_SetElement,
proxy_SetSpecial,
proxy_GetAttributes,
proxy_GetAttributes,
proxy_GetGenericAttributes,
proxy_GetPropertyAttributes,
proxy_GetElementAttributes,
proxy_GetSpecialAttributes,
proxy_SetAttributes,
proxy_SetAttributes,
proxy_SetGenericAttributes,
proxy_SetPropertyAttributes,
proxy_SetElementAttributes,
proxy_SetSpecialAttributes,
proxy_DeleteProperty,

View File

@ -462,7 +462,7 @@ ArrayBuffer::obj_setSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *
}
JSBool
ArrayBuffer::obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
ArrayBuffer::obj_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
*attrsp = JSPROP_PERMANENT | JSPROP_READONLY;
@ -475,6 +475,12 @@ ArrayBuffer::obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *att
return js_GetAttributes(cx, delegate, id, attrsp);
}
JSBool
ArrayBuffer::obj_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
return obj_getGenericAttributes(cx, obj, ATOM_TO_JSID(name), attrsp);
}
JSBool
ArrayBuffer::obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
@ -487,11 +493,11 @@ ArrayBuffer::obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index
JSBool
ArrayBuffer::obj_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return obj_getAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return obj_getGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
}
JSBool
ArrayBuffer::obj_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
ArrayBuffer::obj_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
@ -505,6 +511,12 @@ ArrayBuffer::obj_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *att
return js_SetAttributes(cx, delegate, id, attrsp);
}
JSBool
ArrayBuffer::obj_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
return obj_setGenericAttributes(cx, obj, ATOM_TO_JSID(name), attrsp);
}
JSBool
ArrayBuffer::obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
@ -517,7 +529,7 @@ ArrayBuffer::obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32 index
JSBool
ArrayBuffer::obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return obj_setAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return obj_setGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
}
JSBool
@ -722,7 +734,7 @@ TypedArray::obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid,
}
JSBool
TypedArray::obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
TypedArray::obj_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
*attrsp = (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom))
? JSPROP_PERMANENT | JSPROP_READONLY
@ -730,6 +742,13 @@ TypedArray::obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attr
return true;
}
JSBool
TypedArray::obj_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
*attrsp = JSPROP_PERMANENT | JSPROP_ENUMERATE;
return true;
}
JSBool
TypedArray::obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
@ -740,11 +759,18 @@ TypedArray::obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index,
JSBool
TypedArray::obj_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return obj_getAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return obj_getGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
}
JSBool
TypedArray::obj_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
TypedArray::obj_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
JSBool
TypedArray::obj_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
@ -760,7 +786,8 @@ TypedArray::obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32 index,
JSBool
TypedArray::obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return obj_setAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
/* static */ int
@ -2045,12 +2072,12 @@ Class js::ArrayBufferClass = {
ArrayBuffer::obj_setProperty,
ArrayBuffer::obj_setElement,
ArrayBuffer::obj_setSpecial,
ArrayBuffer::obj_getAttributes,
ArrayBuffer::obj_getAttributes,
ArrayBuffer::obj_getGenericAttributes,
ArrayBuffer::obj_getPropertyAttributes,
ArrayBuffer::obj_getElementAttributes,
ArrayBuffer::obj_getSpecialAttributes,
ArrayBuffer::obj_setAttributes,
ArrayBuffer::obj_setAttributes,
ArrayBuffer::obj_setGenericAttributes,
ArrayBuffer::obj_setPropertyAttributes,
ArrayBuffer::obj_setElementAttributes,
ArrayBuffer::obj_setSpecialAttributes,
ArrayBuffer::obj_deleteProperty,
@ -2149,7 +2176,7 @@ JSFunctionSpec _typedArray::jsfuncs[] = { \
_typedArray::obj_defineProperty, \
_typedArray::obj_defineElement, \
_typedArray::obj_defineSpecial, \
_typedArray::obj_getGeneric, \
_typedArray::obj_getGeneric, \
_typedArray::obj_getProperty, \
_typedArray::obj_getElement, \
_typedArray::obj_getSpecial, \
@ -2157,12 +2184,12 @@ JSFunctionSpec _typedArray::jsfuncs[] = { \
_typedArray::obj_setProperty, \
_typedArray::obj_setElement, \
_typedArray::obj_setSpecial, \
_typedArray::obj_getAttributes, \
_typedArray::obj_getAttributes, \
_typedArray::obj_getGenericAttributes, \
_typedArray::obj_getPropertyAttributes, \
_typedArray::obj_getElementAttributes, \
_typedArray::obj_getSpecialAttributes, \
_typedArray::obj_setAttributes, \
_typedArray::obj_setAttributes, \
_typedArray::obj_setGenericAttributes, \
_typedArray::obj_setPropertyAttributes, \
_typedArray::obj_setElementAttributes, \
_typedArray::obj_setSpecialAttributes, \
_typedArray::obj_deleteProperty, \

View File

@ -122,20 +122,20 @@ struct JS_FRIEND_API(ArrayBuffer) {
obj_setSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict);
static JSBool
obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
obj_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
static JSBool
obj_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp);
static JSBool
obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp);
static JSBool
obj_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp);
static JSBool
obj_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
obj_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
static JSBool
obj_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp);
static JSBool
obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp);
static JSBool
obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp);
@ -222,11 +222,13 @@ struct JS_FRIEND_API(TypedArray) {
static JSBool obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid,
JSObject **objp, JSProperty **propp);
static JSBool obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
static JSBool obj_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
static JSBool obj_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp);
static JSBool obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp);
static JSBool obj_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp);
static JSBool obj_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
static JSBool obj_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
static JSBool obj_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp);
static JSBool obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp);
static JSBool obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp);

View File

@ -4877,7 +4877,7 @@ xml_setSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool st
}
static JSBool
xml_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
xml_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
JSBool found;
if (!HasProperty(cx, obj, IdToJsval(id), &found))
@ -4887,23 +4887,29 @@ xml_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
return JS_TRUE;
}
static JSBool
xml_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
return xml_getGenericAttributes(cx, obj, ATOM_TO_JSID(name), attrsp);
}
static JSBool
xml_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return xml_getAttributes(cx, obj, id, attrsp);
return xml_getGenericAttributes(cx, obj, id, attrsp);
}
static JSBool
xml_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return xml_getAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return xml_getGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
}
static JSBool
xml_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
xml_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
JSBool found;
if (!HasProperty(cx, obj, IdToJsval(id), &found))
@ -4917,19 +4923,25 @@ xml_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
return true;
}
static JSBool
xml_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, uintN *attrsp)
{
return xml_setGenericAttributes(cx, obj, ATOM_TO_JSID(name), attrsp);
}
static JSBool
xml_setElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return xml_setAttributes(cx, obj, id, attrsp);
return xml_setGenericAttributes(cx, obj, id, attrsp);
}
static JSBool
xml_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, uintN *attrsp)
{
return xml_setAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
return xml_setGenericAttributes(cx, obj, SPECIALID_TO_JSID(sid), attrsp);
}
static JSBool
@ -5324,12 +5336,12 @@ JS_FRIEND_DATA(Class) js::XMLClass = {
xml_setProperty,
xml_setElement,
xml_setSpecial,
xml_getAttributes,
xml_getAttributes,
xml_getGenericAttributes,
xml_getPropertyAttributes,
xml_getElementAttributes,
xml_getSpecialAttributes,
xml_setAttributes,
xml_setAttributes,
xml_setGenericAttributes,
xml_setPropertyAttributes,
xml_setElementAttributes,
xml_setSpecialAttributes,
xml_deleteProperty,

View File

@ -3166,7 +3166,7 @@ CopyProperty(JSContext *cx, JSObject *obj, JSObject *referent, jsid id,
if (*objp != referent)
return true;
if (!referent->getGeneric(cx, id, &desc.value) ||
!referent->getAttributes(cx, id, &desc.attrs)) {
!referent->getGenericAttributes(cx, id, &desc.attrs)) {
return false;
}
desc.attrs &= JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;