Bug 594574: Change GetPropertyNames to take its out-parameter by address, not by non-const reference. r=brendan

This commit is contained in:
Jim Blandy 2010-09-21 11:35:29 -07:00
parent 0c4048dcff
commit ff464b7c97
6 changed files with 19 additions and 19 deletions

View File

@ -3831,7 +3831,7 @@ JS_Enumerate(JSContext *cx, JSObject *obj)
AutoIdVector props(cx);
JSIdArray *ida;
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY, props) || !VectorToIdArray(cx, props, &ida))
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY, &props) || !VectorToIdArray(cx, props, &ida))
return false;
for (size_t n = 0; n < size_t(ida->length); ++n)
JS_ASSERT(js_CheckForStringIndex(ida->vector[n]) == ida->vector[n]);

View File

@ -210,7 +210,7 @@ template <class EnumPolicy>
static inline bool
Enumerate(JSContext *cx, JSObject *obj, JSObject *pobj, jsid id,
bool enumerable, bool sharedPermanent, uintN flags, IdSet& ht,
typename EnumPolicy::ResultVector &props)
typename EnumPolicy::ResultVector *props)
{
IdSet::AddPtr p = ht.lookupForAdd(id);
JS_ASSERT_IF(obj == pobj && !obj->isProxy(), !p);
@ -243,7 +243,7 @@ Enumerate(JSContext *cx, JSObject *obj, JSObject *pobj, jsid id,
}
if (enumerable || (flags & JSITER_HIDDEN))
return EnumPolicy::append(cx, props, obj, id, flags);
return EnumPolicy::append(cx, *props, obj, id, flags);
return true;
}
@ -251,11 +251,11 @@ Enumerate(JSContext *cx, JSObject *obj, JSObject *pobj, jsid id,
template <class EnumPolicy>
static bool
EnumerateNativeProperties(JSContext *cx, JSObject *obj, JSObject *pobj, uintN flags, IdSet &ht,
typename EnumPolicy::ResultVector &props)
typename EnumPolicy::ResultVector *props)
{
JS_LOCK_OBJ(cx, pobj);
size_t initialLength = props.length();
size_t initialLength = props->length();
/* Collect all unique properties from this object's scope. */
for (Shape::Range r = pobj->lastProperty()->all(); !r.empty(); r.popFront()) {
@ -270,7 +270,7 @@ EnumerateNativeProperties(JSContext *cx, JSObject *obj, JSObject *pobj, uintN fl
}
}
Reverse(props.begin() + initialLength, props.end());
Reverse(props->begin() + initialLength, props->end());
JS_UNLOCK_OBJ(cx, pobj);
return true;
@ -279,7 +279,7 @@ EnumerateNativeProperties(JSContext *cx, JSObject *obj, JSObject *pobj, uintN fl
template <class EnumPolicy>
static bool
EnumerateDenseArrayProperties(JSContext *cx, JSObject *obj, JSObject *pobj, uintN flags,
IdSet &ht, typename EnumPolicy::ResultVector &props)
IdSet &ht, typename EnumPolicy::ResultVector *props)
{
if (!Enumerate<EnumPolicy>(cx, obj, pobj, ATOM_TO_JSID(cx->runtime->atomState.lengthAtom), false, true,
flags, ht, props)) {
@ -303,7 +303,7 @@ EnumerateDenseArrayProperties(JSContext *cx, JSObject *obj, JSObject *pobj, uint
template <class EnumPolicy>
static bool
Snapshot(JSContext *cx, JSObject *obj, uintN flags, typename EnumPolicy::ResultVector &props)
Snapshot(JSContext *cx, JSObject *obj, uintN flags, typename EnumPolicy::ResultVector *props)
{
/*
* FIXME: Bug 575997 - We won't need to initialize this hash table if
@ -389,7 +389,7 @@ VectorToIdArray(JSContext *cx, AutoIdVector &props, JSIdArray **idap)
}
bool
GetPropertyNames(JSContext *cx, JSObject *obj, uintN flags, AutoIdVector &props)
GetPropertyNames(JSContext *cx, JSObject *obj, uintN flags, AutoIdVector *props)
{
return Snapshot<KeyEnumeration>(cx, obj, flags & (JSITER_OWNONLY | JSITER_HIDDEN), props);
}
@ -697,14 +697,14 @@ GetIterator(JSContext *cx, JSObject *obj, uintN flags, Value *vp)
if (flags & JSITER_FOREACH) {
AutoValueVector vals(cx);
if (JS_LIKELY(obj != NULL) && !Snapshot<ValueEnumeration>(cx, obj, flags, vals))
if (JS_LIKELY(obj != NULL) && !Snapshot<ValueEnumeration>(cx, obj, flags, &vals))
return false;
JS_ASSERT(shapes.empty());
if (!VectorToValueIterator(cx, obj, flags, vals, vp))
return false;
} else {
AutoIdVector keys(cx);
if (JS_LIKELY(obj != NULL) && !Snapshot<KeyEnumeration>(cx, obj, flags, keys))
if (JS_LIKELY(obj != NULL) && !Snapshot<KeyEnumeration>(cx, obj, flags, &keys))
return false;
if (!VectorToKeyIterator(cx, obj, flags, keys, shapes.length(), key, vp))
return false;

View File

@ -138,7 +138,7 @@ bool
VectorToIdArray(JSContext *cx, js::AutoIdVector &props, JSIdArray **idap);
bool
GetPropertyNames(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector &props);
GetPropertyNames(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector *props);
bool
GetIterator(JSContext *cx, JSObject *obj, uintN flags, js::Value *vp);

View File

@ -1796,7 +1796,7 @@ obj_keys(JSContext *cx, uintN argc, Value *vp)
return JS_FALSE;
AutoIdVector props(cx);
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY, props))
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY, &props))
return JS_FALSE;
AutoValueVector vals(cx);
@ -2490,7 +2490,7 @@ obj_getOwnPropertyNames(JSContext *cx, uintN argc, Value *vp)
return false;
AutoIdVector keys(cx);
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY | JSITER_HIDDEN, keys))
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY | JSITER_HIDDEN, &keys))
return false;
AutoValueVector vals(cx);

View File

@ -345,7 +345,7 @@ JO(JSContext *cx, Value *vp, StringifyContext *scx)
JSBool memberWritten = JS_FALSE;
AutoIdVector props(cx);
if (!GetPropertyNames(cx, &keySource->toObject(), JSITER_OWNONLY, props))
if (!GetPropertyNames(cx, &keySource->toObject(), JSITER_OWNONLY, &props))
return JS_FALSE;
for (size_t i = 0, len = props.length(); i < len; i++) {
@ -608,7 +608,7 @@ Walk(JSContext *cx, jsid id, JSObject *holder, const Value &reviver, Value *vp)
}
} else {
AutoIdVector props(cx);
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY, props))
if (!GetPropertyNames(cx, obj, JSITER_OWNONLY, &props))
return false;
for (size_t i = 0, len = props.length(); i < len; i++) {

View File

@ -135,7 +135,7 @@ bool
JSWrapper::getOwnPropertyNames(JSContext *cx, JSObject *wrapper, AutoIdVector &props)
{
jsid id = JSID_VOID;
GET(GetPropertyNames(cx, wrappedObject(wrapper), JSITER_OWNONLY | JSITER_HIDDEN, props));
GET(GetPropertyNames(cx, wrappedObject(wrapper), JSITER_OWNONLY | JSITER_HIDDEN, &props));
}
static bool
@ -157,7 +157,7 @@ bool
JSWrapper::enumerate(JSContext *cx, JSObject *wrapper, AutoIdVector &props)
{
static jsid id = JSID_VOID;
GET(GetPropertyNames(cx, wrappedObject(wrapper), 0, props));
GET(GetPropertyNames(cx, wrappedObject(wrapper), 0, &props));
}
bool
@ -207,7 +207,7 @@ bool
JSWrapper::enumerateOwn(JSContext *cx, JSObject *wrapper, AutoIdVector &props)
{
const jsid id = JSID_VOID;
GET(GetPropertyNames(cx, wrappedObject(wrapper), JSITER_OWNONLY, props));
GET(GetPropertyNames(cx, wrappedObject(wrapper), JSITER_OWNONLY, &props));
}
bool