Bug 1142784, part 1 - In NativeObject.cpp, move some Lookup functions out of the way and make a big swath of this file the [[DefineOwnProperty]] section. r=Waldo.

This commit is contained in:
Jason Orendorff 2015-02-17 12:01:54 -06:00
parent 98194bf6a0
commit e72f4ca876

View File

@ -981,6 +981,59 @@ NativeObject::addDataProperty(ExclusiveContext *cx, HandlePropertyName name,
return addProperty(cx, self, id, nullptr, nullptr, slot, attrs, 0);
}
template <AllowGC allowGC>
bool
js::NativeLookupOwnProperty(ExclusiveContext *cx,
typename MaybeRooted<NativeObject*, allowGC>::HandleType obj,
typename MaybeRooted<jsid, allowGC>::HandleType id,
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp)
{
bool done;
return LookupOwnPropertyInline<allowGC>(cx, obj, id, propp, &done);
}
template bool
js::NativeLookupOwnProperty<CanGC>(ExclusiveContext *cx, HandleNativeObject obj, HandleId id,
MutableHandleShape propp);
template bool
js::NativeLookupOwnProperty<NoGC>(ExclusiveContext *cx, NativeObject *obj, jsid id,
FakeMutableHandle<Shape*> propp);
template <AllowGC allowGC>
bool
js::NativeLookupProperty(ExclusiveContext *cx,
typename MaybeRooted<NativeObject*, allowGC>::HandleType obj,
typename MaybeRooted<jsid, allowGC>::HandleType id,
typename MaybeRooted<JSObject*, allowGC>::MutableHandleType objp,
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp)
{
return LookupPropertyInline<allowGC>(cx, obj, id, objp, propp);
}
template bool
js::NativeLookupProperty<CanGC>(ExclusiveContext *cx, HandleNativeObject obj, HandleId id,
MutableHandleObject objp, MutableHandleShape propp);
template bool
js::NativeLookupProperty<NoGC>(ExclusiveContext *cx, NativeObject *obj, jsid id,
FakeMutableHandle<JSObject*> objp,
FakeMutableHandle<Shape*> propp);
bool
js::NativeLookupElement(JSContext *cx, HandleNativeObject obj, uint32_t index,
MutableHandleObject objp, MutableHandleShape propp)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
return false;
return LookupPropertyInline<CanGC>(cx, obj, id, objp, propp);
}
/*** [[DefineOwnProperty]] ***********************************************************************/
/*
* Backward compatibility requires allowing addProperty hooks to mutate the
* nominal initial value of a slotful property, while GC safety wants that
@ -1445,56 +1498,6 @@ js::NativeDefineProperty(ExclusiveContext *cx, HandleNativeObject obj, HandleId
return result.succeed();
}
template <AllowGC allowGC>
bool
js::NativeLookupOwnProperty(ExclusiveContext *cx,
typename MaybeRooted<NativeObject*, allowGC>::HandleType obj,
typename MaybeRooted<jsid, allowGC>::HandleType id,
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp)
{
bool done;
return LookupOwnPropertyInline<allowGC>(cx, obj, id, propp, &done);
}
template bool
js::NativeLookupOwnProperty<CanGC>(ExclusiveContext *cx, HandleNativeObject obj, HandleId id,
MutableHandleShape propp);
template bool
js::NativeLookupOwnProperty<NoGC>(ExclusiveContext *cx, NativeObject *obj, jsid id,
FakeMutableHandle<Shape*> propp);
template <AllowGC allowGC>
bool
js::NativeLookupProperty(ExclusiveContext *cx,
typename MaybeRooted<NativeObject*, allowGC>::HandleType obj,
typename MaybeRooted<jsid, allowGC>::HandleType id,
typename MaybeRooted<JSObject*, allowGC>::MutableHandleType objp,
typename MaybeRooted<Shape*, allowGC>::MutableHandleType propp)
{
return LookupPropertyInline<allowGC>(cx, obj, id, objp, propp);
}
template bool
js::NativeLookupProperty<CanGC>(ExclusiveContext *cx, HandleNativeObject obj, HandleId id,
MutableHandleObject objp, MutableHandleShape propp);
template bool
js::NativeLookupProperty<NoGC>(ExclusiveContext *cx, NativeObject *obj, jsid id,
FakeMutableHandle<JSObject*> objp,
FakeMutableHandle<Shape*> propp);
bool
js::NativeLookupElement(JSContext *cx, HandleNativeObject obj, uint32_t index,
MutableHandleObject objp, MutableHandleShape propp)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
return false;
return LookupPropertyInline<CanGC>(cx, obj, id, objp, propp);
}
bool
js::NativeDefineProperty(ExclusiveContext *cx, HandleNativeObject obj, PropertyName *name,
HandleValue value, GetterOp getter, SetterOp setter,
@ -1552,6 +1555,7 @@ js::NativeDefineProperty(ExclusiveContext *cx, HandleNativeObject obj, PropertyN
return NativeDefineProperty(cx, obj, id, value, getter, setter, attrs);
}
/*** [[HasProperty]] *****************************************************************************/
// ES6 draft rev31 9.1.7.1 OrdinaryHasProperty