Bug 903352 - Handlify remaining PropertyDescriptor APIs r=terrence r=bholley r=smaug

This commit is contained in:
Jon Coppeard 2013-08-12 12:09:14 +01:00
parent 6c7d61e401
commit 11678aa48c
22 changed files with 115 additions and 130 deletions

View File

@ -194,7 +194,7 @@ public:
static bool IsImageSrcSetDisabled();
static bool LookupBindingMember(JSContext* aCx, nsIContent *aContent,
JS::HandleId aId, JSPropertyDescriptor* aDesc);
JS::HandleId aId, JS::MutableHandle<JSPropertyDescriptor> aDesc);
/**
* Returns the parent node of aChild crossing document boundaries.

View File

@ -1756,7 +1756,7 @@ nsContentUtils::IsImageSrcSetDisabled()
// static
bool
nsContentUtils::LookupBindingMember(JSContext* aCx, nsIContent *aContent,
JS::HandleId aId, JSPropertyDescriptor* aDesc)
JS::HandleId aId, JS::MutableHandle<JSPropertyDescriptor> aDesc)
{
nsXBLBinding* binding = aContent->GetXBLBinding();
if (!binding)

View File

@ -1105,10 +1105,10 @@ nsXBLBinding::ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const
bool
nsXBLBinding::LookupMember(JSContext* aCx, JS::HandleId aId,
JSPropertyDescriptor* aDesc)
JS::MutableHandle<JSPropertyDescriptor> aDesc)
{
// We should never enter this function with a pre-filled property descriptor.
MOZ_ASSERT(!aDesc->obj);
MOZ_ASSERT(!aDesc.object());
// Get the string as an nsString before doing anything, so we can make
// convenient comparisons during our search.
@ -1148,7 +1148,7 @@ nsXBLBinding::LookupMember(JSContext* aCx, JS::HandleId aId,
bool
nsXBLBinding::LookupMemberInternal(JSContext* aCx, nsString& aName,
JS::HandleId aNameAsId,
JSPropertyDescriptor* aDesc,
JS::MutableHandle<JSPropertyDescriptor> aDesc,
JS::Handle<JSObject*> aXBLScope)
{
// First, see if we have a JSClass. If we don't, it means that this binding
@ -1186,7 +1186,7 @@ nsXBLBinding::LookupMemberInternal(JSContext* aCx, nsString& aName,
{
return false;
}
if (aDesc->obj || !mNextBinding) {
if (aDesc.object() || !mNextBinding) {
return true;
}

View File

@ -81,7 +81,7 @@ public:
* May only be called when XBL code is being run in a separate scope, because
* otherwise we don't have untainted data with which to do a proper lookup.
*/
bool LookupMember(JSContext* aCx, JS::HandleId aId, JSPropertyDescriptor* aDesc);
bool LookupMember(JSContext* aCx, JS::HandleId aId, JS::MutableHandle<JSPropertyDescriptor> aDesc);
/*
* Determines whether the binding has a field with the given name.
@ -94,7 +94,8 @@ protected:
* Internal version. Requires that aCx is in appropriate xbl scope.
*/
bool LookupMemberInternal(JSContext* aCx, nsString& aName, JS::HandleId aNameAsId,
JSPropertyDescriptor* aDesc, JS::Handle<JSObject*> aXBLScope);
JS::MutableHandle<JSPropertyDescriptor> aDesc,
JS::Handle<JSObject*> aXBLScope);
public:

View File

@ -216,7 +216,7 @@ nsXBLProtoImpl::CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding)
bool
nsXBLProtoImpl::LookupMember(JSContext* aCx, nsString& aName,
JS::HandleId aNameAsId,
JSPropertyDescriptor* aDesc,
JS::MutableHandle<JSPropertyDescriptor> aDesc,
JSObject* aClassObject)
{
for (nsXBLProtoImplMember* m = mMembers; m; m = m->GetNext()) {

View File

@ -19,34 +19,34 @@ class nsXBLProtoImplAnonymousMethod;
class nsXBLProtoImpl
{
public:
nsXBLProtoImpl()
nsXBLProtoImpl()
: mClassObject(nullptr),
mMembers(nullptr),
mFields(nullptr),
mConstructor(nullptr),
mDestructor(nullptr)
{
MOZ_COUNT_CTOR(nsXBLProtoImpl);
{
MOZ_COUNT_CTOR(nsXBLProtoImpl);
}
~nsXBLProtoImpl()
{
~nsXBLProtoImpl()
{
MOZ_COUNT_DTOR(nsXBLProtoImpl);
// Note: the constructor and destructor are in mMembers, so we'll
// clean them up automatically.
delete mMembers;
delete mFields;
}
nsresult InstallImplementation(nsXBLPrototypeBinding* aPrototypeBinding, nsXBLBinding* aBinding);
nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding,
nsIContent* aBoundElement,
nsIContent* aBoundElement,
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
JS::MutableHandle<JSObject*> aTargetClassObject,
bool* aTargetIsNew);
nsresult CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding);
bool LookupMember(JSContext* aCx, nsString& aName, JS::HandleId aNameAsId,
JSPropertyDescriptor* aDesc, JSObject* aClassObject);
JS::MutableHandle<JSPropertyDescriptor> aDesc, JSObject* aClassObject);
void SetMemberList(nsXBLProtoImplMember* aMemberList)
{
@ -95,9 +95,9 @@ protected:
}
void DestroyMembers();
public:
nsCString mClassName; // The name of the class.
nsCString mClassName; // The name of the class.
protected:
JSObject* mClassObject; // The class object for the binding. We'll use this to pre-compile properties
@ -106,15 +106,15 @@ protected:
nsXBLProtoImplMember* mMembers; // The members of an implementation are chained in this singly-linked list.
nsXBLProtoImplField* mFields; // Our fields
public:
nsXBLProtoImplAnonymousMethod* mConstructor; // Our class constructor.
nsXBLProtoImplAnonymousMethod* mDestructor; // Our class destructor.
};
nsresult
NS_NewXBLProtoImpl(nsXBLPrototypeBinding* aBinding,
const PRUnichar* aClassName,
NS_NewXBLProtoImpl(nsXBLPrototypeBinding* aBinding,
const PRUnichar* aClassName,
nsXBLProtoImpl** aResult);
#endif // nsXBLProtoImpl_h__

View File

@ -829,7 +829,7 @@ static bool
XrayResolveAttribute(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
const Prefable<const JSPropertySpec>* attributes, jsid* attributeIds,
const JSPropertySpec* attributeSpecs, JSPropertyDescriptor* desc)
const JSPropertySpec* attributeSpecs, JS::MutableHandle<JSPropertyDescriptor> desc)
{
for (; attributes->specs; ++attributes) {
if (attributes->isEnabled(cx, obj)) {
@ -842,7 +842,7 @@ XrayResolveAttribute(JSContext* cx, JS::Handle<JSObject*> wrapper,
// Because of centralization, we need to make sure we fault in the
// JitInfos as well. At present, until the JSAPI changes, the easiest
// way to do this is wrap them up as functions ourselves.
desc->attrs = attrSpec.flags & ~JSPROP_NATIVE_ACCESSORS;
desc.setAttributes(attrSpec.flags & ~JSPROP_NATIVE_ACCESSORS);
// They all have getters, so we can just make it.
JS::Rooted<JSObject*> global(cx, JS_GetGlobalForObject(cx, wrapper));
JS::Rooted<JSFunction*> fun(cx,
@ -852,8 +852,8 @@ XrayResolveAttribute(JSContext* cx, JS::Handle<JSObject*> wrapper,
return false;
SET_JITINFO(fun, attrSpec.getter.info);
JSObject *funobj = JS_GetFunctionObject(fun);
desc->getter = js::CastAsJSPropertyOp(funobj);
desc->attrs |= JSPROP_GETTER;
desc.setGetterObject(funobj);
desc.attributesRef() |= JSPROP_GETTER;
if (attrSpec.setter.op) {
// We have a setter! Make it.
fun = JS_NewFunctionById(cx, (JSNative)attrSpec.setter.op, 1, 0,
@ -862,12 +862,12 @@ XrayResolveAttribute(JSContext* cx, JS::Handle<JSObject*> wrapper,
return false;
SET_JITINFO(fun, attrSpec.setter.info);
funobj = JS_GetFunctionObject(fun);
desc->setter = js::CastAsJSStrictPropertyOp(funobj);
desc->attrs |= JSPROP_SETTER;
desc.setSetterObject(funobj);
desc.attributesRef() |= JSPROP_SETTER;
} else {
desc->setter = nullptr;
desc.setSetter(nullptr);
}
desc->obj = wrapper;
desc.object().set(wrapper);
return true;
}
}
@ -879,7 +879,7 @@ XrayResolveAttribute(JSContext* cx, JS::Handle<JSObject*> wrapper,
static bool
XrayResolveProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
JSPropertyDescriptor* desc, DOMObjectType type,
JS::MutableHandle<JSPropertyDescriptor> desc, DOMObjectType type,
const NativeProperties* nativeProperties)
{
const Prefable<const JSFunctionSpec>* methods;
@ -912,11 +912,11 @@ XrayResolveProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
}
SET_JITINFO(fun, methodSpec.call.info);
JSObject *funobj = JS_GetFunctionObject(fun);
desc->value.setObject(*funobj);
desc->attrs = methodSpec.flags;
desc->obj = wrapper;
desc->setter = nullptr;
desc->getter = nullptr;
desc.value().setObject(*funobj);
desc.setAttributes(methodSpec.flags);
desc.object().set(wrapper);
desc.setSetter(nullptr);
desc.setGetter(nullptr);
return true;
}
}
@ -932,7 +932,7 @@ XrayResolveProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
nativeProperties->staticAttributeSpecs, desc)) {
return false;
}
if (desc->obj) {
if (desc.object()) {
return true;
}
}
@ -944,7 +944,7 @@ XrayResolveProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
nativeProperties->attributeSpecs, desc)) {
return false;
}
if (desc->obj) {
if (desc.object()) {
return true;
}
}
@ -956,7 +956,7 @@ XrayResolveProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
desc)) {
return false;
}
if (desc->obj) {
if (desc.object()) {
return true;
}
}
@ -971,9 +971,9 @@ XrayResolveProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
size_t i = constant->specs - nativeProperties->constantSpecs;
for ( ; nativeProperties->constantIds[i] != JSID_VOID; ++i) {
if (id == nativeProperties->constantIds[i]) {
desc->attrs = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
desc->obj = wrapper;
desc->value = nativeProperties->constantSpecs[i].value;
desc.setAttributes(JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
desc.object().set(wrapper);
desc.value().set(nativeProperties->constantSpecs[i].value);
return true;
}
}
@ -988,7 +988,7 @@ static bool
ResolvePrototypeOrConstructor(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj,
size_t protoAndIfaceArrayIndex, unsigned attrs,
JSPropertyDescriptor* desc)
JS::MutableHandle<JSPropertyDescriptor> desc)
{
JS::Rooted<JSObject*> global(cx, js::GetGlobalForObjectCrossCompartment(obj));
{
@ -998,12 +998,12 @@ ResolvePrototypeOrConstructor(JSContext* cx, JS::Handle<JSObject*> wrapper,
if (!protoOrIface) {
return false;
}
desc->obj = wrapper;
desc->shortid = 0;
desc->attrs = attrs;
desc->getter = JS_PropertyStub;
desc->setter = JS_StrictPropertyStub;
desc->value = JS::ObjectValue(*protoOrIface);
desc.object().set(wrapper);
desc.setShortId(0);
desc.setAttributes(attrs);
desc.setGetter(JS_PropertyStub);
desc.setSetter(JS_StrictPropertyStub);
desc.value().set(JS::ObjectValue(*protoOrIface));
}
return JS_WrapPropertyDescriptor(cx, desc);
}
@ -1013,7 +1013,7 @@ XrayResolveNativeProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
const NativePropertyHooks* nativePropertyHooks,
DOMObjectType type, JS::Handle<JSObject*> obj,
JS::Handle<jsid> id,
JSPropertyDescriptor* desc)
JS::MutableHandle<JSPropertyDescriptor> desc)
{
if (type == eInterface && IdEquals(id, "prototype")) {
return nativePropertyHooks->mPrototypeID == prototypes::id::_ID_Count ||
@ -1039,7 +1039,7 @@ XrayResolveNativeProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
return false;
}
if (!desc->obj &&
if (!desc.object() &&
nativeProperties.chromeOnly &&
xpc::AccessCheck::isChrome(js::GetObjectCompartment(wrapper)) &&
!XrayResolveProperty(cx, wrapper, obj, id, desc, type,
@ -1053,7 +1053,7 @@ XrayResolveNativeProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
bool
XrayResolveNativeProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj,
JS::Handle<jsid> id, JSPropertyDescriptor* desc)
JS::Handle<jsid> id, JS::MutableHandle<JSPropertyDescriptor> desc)
{
DOMObjectType type;
const NativePropertyHooks* nativePropertyHooks =
@ -1072,7 +1072,7 @@ XrayResolveNativeProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
return false;
}
if (desc->obj) {
if (desc.object()) {
return true;
}
} while ((nativePropertyHooks = nativePropertyHooks->mProtoHooks));
@ -1459,8 +1459,7 @@ NativeToString(JSContext* cx, JS::Handle<JSObject*> wrapper,
toStringDesc.value().set(JS::UndefinedValue());
JS::Rooted<jsid> id(cx,
nsXPConnect::GetRuntimeInstance()->GetStringID(XPCJSRuntime::IDX_TO_STRING));
if (!XrayResolveNativeProperty(cx, wrapper, obj, id,
toStringDesc.address())) {
if (!XrayResolveNativeProperty(cx, wrapper, obj, id, &toStringDesc)) {
return false;
}

View File

@ -1924,7 +1924,7 @@ XrayResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
bool
XrayResolveNativeProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj,
JS::Handle<jsid> id, JSPropertyDescriptor* desc);
JS::Handle<jsid> id, JS::MutableHandle<JSPropertyDescriptor> desc);
/**
* Define a property on obj through an Xray wrapper.

View File

@ -7125,7 +7125,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
"}\n") % (self.descriptor.nativeType)
if UseHolderForUnforgeable(self.descriptor):
getUnforgeable = """if (!JS_GetPropertyDescriptorById(cx, ${holder}, id, flags, desc.address())) {
getUnforgeable = """if (!JS_GetPropertyDescriptorById(cx, ${holder}, id, flags, desc)) {
return false;
}
MOZ_ASSERT_IF(desc.object(), desc.object() == ${holder});"""
@ -7133,7 +7133,7 @@ MOZ_ASSERT_IF(desc.object(), desc.object() == ${holder});"""
getUnforgeable, "isXray")
getUnforgeable += """if (desc.object()) {
desc.object().set(proxy);
return !isXray || JS_WrapPropertyDescriptor(cx, desc.address());
return !isXray || JS_WrapPropertyDescriptor(cx, desc);
}
"""
@ -7202,7 +7202,7 @@ MOZ_ASSERT_IF(desc.object(), desc.object() == ${holder});"""
return setOrIndexedGet + """JS::Rooted<JSObject*> expando(cx);
if (!isXray && (expando = GetExpandoObject(proxy))) {
if (!JS_GetPropertyDescriptorById(cx, expando, id, flags, desc.address())) {
if (!JS_GetPropertyDescriptorById(cx, expando, id, flags, desc)) {
return false;
}
if (desc.object()) {

View File

@ -182,7 +182,7 @@ BaseDOMProxyHandler::getPropertyDescriptor(JSContext* cx,
return true;
}
return JS_GetPropertyDescriptorById(cx, proto, id, 0, desc.address());
return JS_GetPropertyDescriptorById(cx, proto, id, 0, desc);
}
bool

View File

@ -189,7 +189,7 @@ JavaScriptChild::AnswerGetPropertyDescriptor(const ObjectId &objId, const nsStri
return fail(cx, rs);
Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, flags, desc.address()))
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, flags, &desc))
return fail(cx, rs);
if (!desc.object())
@ -222,7 +222,7 @@ JavaScriptChild::AnswerGetOwnPropertyDescriptor(const ObjectId &objId, const nsS
return fail(cx, rs);
Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, flags, desc.address()))
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, flags, &desc))
return fail(cx, rs);
if (desc.object() != obj)
@ -339,10 +339,10 @@ JavaScriptChild::AnswerHasOwn(const ObjectId &objId, const nsString &id, ReturnS
if (!convertGeckoStringToId(cx, id, &internedId))
return fail(cx, rs);
JSPropertyDescriptor desc;
Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, obj, internedId, 0, &desc))
return fail(cx, rs);
*bp = (desc.obj == obj);
*bp = (desc.object() == obj);
return ok(rs);
}

View File

@ -46,17 +46,17 @@ GetDataProperty(JSContext *cx, const Value &objVal, HandlePropertyName field, Mu
if (!objVal.isObject())
return LinkFail(cx, "accessing property of non-object");
JSPropertyDescriptor desc;
Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, &objVal.toObject(), NameToId(field), 0, &desc))
return false;
if (!desc.obj)
if (!desc.object())
return LinkFail(cx, "property not present on object");
if (desc.attrs & (JSPROP_GETTER | JSPROP_SETTER))
if (desc.hasGetterOrSetterObject())
return LinkFail(cx, "property is not a data property");
v.set(desc.value);
v.set(desc.value());
return true;
}

View File

@ -3601,7 +3601,7 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned
if (!LookupPropertyById(cx, obj, id, flags, &obj2, &shape))
return false;
JS_ASSERT(desc.isClear());
desc.clear();
if (!shape || (own && obj != obj2))
return true;
@ -3636,15 +3636,11 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned
JS_PUBLIC_API(bool)
JS_GetPropertyDescriptorById(JSContext *cx, JSObject *objArg, jsid idArg, unsigned flags,
JSPropertyDescriptor *desc_)
MutableHandle<JSPropertyDescriptor> desc)
{
RootedObject obj(cx, objArg);
RootedId id(cx, idArg);
Rooted<PropertyDescriptor> desc(cx);
if (!GetPropertyDescriptorById(cx, obj, id, flags, false, &desc))
return false;
*desc_ = desc;
return true;
return GetPropertyDescriptorById(cx, obj, id, flags, false, desc);
}
JS_PUBLIC_API(bool)

View File

@ -3478,11 +3478,6 @@ class PropertyDescriptorOperations
JS::Handle<Value> value() const {
return JS::Handle<Value>::fromMarkedLocation(&desc()->value);
}
bool isClear() const {
return desc()->obj == NULL && desc()->attrs == 0 && desc()->getter == NULL &&
desc()->setter == NULL && desc()->value.isUndefined();
}
};
template <typename Outer>
@ -3491,6 +3486,16 @@ class MutablePropertyDescriptorOperations : public PropertyDescriptorOperations<
JSPropertyDescriptor * desc() { return static_cast<Outer*>(this)->extractMutable(); }
public:
void clear() {
object().set(NULL);
setAttributes(0);
setShortId(0);
setGetter(NULL);
setSetter(NULL);
value().setUndefined();
}
JS::MutableHandle<JSObject*> object() {
return JS::MutableHandle<JSObject*>::fromMarkedLocation(&desc()->obj);
}
@ -3574,7 +3579,7 @@ class MutableHandleBase<JSPropertyDescriptor>
*/
extern JS_PUBLIC_API(bool)
JS_GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, unsigned flags,
JSPropertyDescriptor *desc);
JS::MutableHandle<JSPropertyDescriptor> desc);
extern JS_PUBLIC_API(bool)
JS_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle<JS::Value> vp);

View File

@ -244,12 +244,9 @@ JS_SetCompartmentPrincipals(JSCompartment *compartment, JSPrincipals *principals
}
JS_FRIEND_API(bool)
JS_WrapPropertyDescriptor(JSContext *cx, js::PropertyDescriptor *descArg)
JS_WrapPropertyDescriptor(JSContext *cx, JS::MutableHandle<js::PropertyDescriptor> desc)
{
Rooted<PropertyDescriptor> desc(cx, *descArg);
bool status = cx->compartment()->wrap(cx, &desc);
*descArg = desc;
return status;
return cx->compartment()->wrap(cx, desc);
}
JS_FRIEND_API(bool)
@ -1092,11 +1089,10 @@ js::GetObjectMetadata(JSObject *obj)
JS_FRIEND_API(bool)
js_DefineOwnProperty(JSContext *cx, JSObject *objArg, jsid idArg,
const js::PropertyDescriptor& descriptorArg, bool *bp)
JS::Handle<js::PropertyDescriptor> descriptor, bool *bp)
{
RootedObject obj(cx, objArg);
RootedId id(cx, idArg);
Rooted<PropertyDescriptor> descriptor(cx, descriptorArg);
JS_ASSERT(cx->runtime()->heapState == js::Idle);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id, descriptor.value());

View File

@ -175,7 +175,7 @@ extern JS_FRIEND_API(bool)
JS_CopyPropertiesFrom(JSContext *cx, JSObject *target, JSObject *obj);
extern JS_FRIEND_API(bool)
JS_WrapPropertyDescriptor(JSContext *cx, JSPropertyDescriptor *desc);
JS_WrapPropertyDescriptor(JSContext *cx, JS::MutableHandle<JSPropertyDescriptor> desc);
extern JS_FRIEND_API(bool)
JS_WrapAutoIdVector(JSContext *cx, JS::AutoIdVector &props);
@ -575,18 +575,6 @@ AtomToLinearString(JSAtom *atom)
return reinterpret_cast<JSLinearString *>(atom);
}
static inline JSPropertyOp
CastAsJSPropertyOp(JSObject *object)
{
return JS_DATA_TO_FUNC_PTR(JSPropertyOp, object);
}
static inline JSStrictPropertyOp
CastAsJSStrictPropertyOp(JSObject *object)
{
return JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, object);
}
JS_FRIEND_API(bool)
GetPropertyNames(JSContext *cx, JSObject *obj, unsigned flags, js::AutoIdVector *props);
@ -1816,7 +1804,7 @@ class AsmJSModuleSourceDesc
extern JS_FRIEND_API(bool)
js_DefineOwnProperty(JSContext *cx, JSObject *objArg, jsid idArg,
const JSPropertyDescriptor& descriptor, bool *bp);
JS::Handle<JSPropertyDescriptor> descriptor, bool *bp);
extern JS_FRIEND_API(bool)
js_ReportIsNotFunction(JSContext *cx, const JS::Value& v);

View File

@ -370,7 +370,7 @@ DirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, Han
assertEnteredPolicy(cx, proxy, id);
JS_ASSERT(!hasPrototype()); // Should never be called if there's a prototype.
RootedObject target(cx, proxy->as<ProxyObject>().target());
return JS_GetPropertyDescriptorById(cx, target, id, 0, desc.address());
return JS_GetPropertyDescriptorById(cx, target, id, 0, desc);
}
static bool
@ -382,7 +382,7 @@ GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, unsigned
if (obj->is<ProxyObject>())
return Proxy::getOwnPropertyDescriptor(cx, obj, id, desc, flags);
if (!JS_GetPropertyDescriptorById(cx, obj, id, flags, desc.address()))
if (!JS_GetPropertyDescriptorById(cx, obj, id, flags, desc))
return false;
if (desc.object() != obj)
desc.object().set(NULL);
@ -553,7 +553,7 @@ DirectProxyHandler::hasOwn(JSContext *cx, HandleObject proxy, HandleId id, bool
assertEnteredPolicy(cx, proxy, id);
RootedObject target(cx, proxy->as<ProxyObject>().target());
Rooted<PropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, target, id, 0, desc.address()))
if (!JS_GetPropertyDescriptorById(cx, target, id, 0, &desc))
return false;
*bp = (desc.object() == target);
return true;
@ -1321,7 +1321,7 @@ static bool
HasOwn(JSContext *cx, HandleObject obj, HandleId id, bool *bp)
{
Rooted<PropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, obj, id, 0, desc.address()))
if (!JS_GetPropertyDescriptorById(cx, obj, id, 0, &desc))
return false;
*bp = (desc.object() == obj);
return true;
@ -1716,7 +1716,7 @@ ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject pr
JS_ASSERT(!desc.object());
return true;
}
return JS_GetPropertyDescriptorById(cx, proto, id, 0, desc.address());
return JS_GetPropertyDescriptorById(cx, proto, id, 0, desc);
}
bool
@ -2310,8 +2310,7 @@ Proxy::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
return false;
if (desc.object())
return true;
INVOKE_ON_PROTOTYPE(cx, handler, proxy,
JS_GetPropertyDescriptorById(cx, proto, id, 0, desc.address()));
INVOKE_ON_PROTOTYPE(cx, handler, proxy, JS_GetPropertyDescriptorById(cx, proto, id, 0, desc));
}
bool
@ -2544,7 +2543,7 @@ Proxy::set(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id
return false;
if (proto) {
Rooted<PropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, proto, id, 0, desc.address()))
if (!JS_GetPropertyDescriptorById(cx, proto, id, 0, &desc))
return false;
if (desc.object() && desc.setter())
return JSObject::setGeneric(cx, proto, receiver, id, vp, strict);

View File

@ -1415,7 +1415,7 @@ class DebugScopeProxy : public BaseProxyHandler
return true;
}
return JS_GetPropertyDescriptorById(cx, scope, id, 0, desc.address());
return JS_GetPropertyDescriptorById(cx, scope, id, 0, desc);
}
bool get(JSContext *cx, HandleObject proxy, HandleObject receiver, HandleId id,

View File

@ -2693,7 +2693,7 @@ nsXPCComponents_Utils::LookupMethod(const JS::Value& object,
// Alright, now do the lookup.
*retval = UndefinedValue();
Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, xray, methodId, 0, desc.address()))
if (!JS_GetPropertyDescriptorById(cx, xray, methodId, 0, &desc))
return NS_ERROR_FAILURE;
// First look for a method value. If that's not there, try a getter,
@ -3141,7 +3141,7 @@ xpc::SandboxProxyHandler::getPropertyDescriptor(JSContext *cx,
MOZ_ASSERT(js::GetObjectCompartment(obj) == js::GetObjectCompartment(proxy));
if (!JS_GetPropertyDescriptorById(cx, obj, id,
flags, desc.address()))
flags, desc))
return false;
if (!desc.object())

View File

@ -348,7 +348,7 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapperArg, jsid idArg, Wr
Access access = NO_ACCESS;
Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, hallpass, id, 0, desc.address())) {
if (!JS_GetPropertyDescriptorById(cx, hallpass, id, 0, &desc)) {
return false; // Error
}
if (!desc.object() || !desc.isEnumerable())

View File

@ -90,7 +90,7 @@ ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx,
// If not, try doing the lookup on the prototype.
MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
return JS_GetPropertyDescriptorById(cx, wrapperProto, id, 0, desc.address());
return JS_GetPropertyDescriptorById(cx, wrapperProto, id, 0, desc);
}
bool
@ -115,7 +115,7 @@ ChromeObjectWrapper::has(JSContext *cx, HandleObject wrapper,
// Try the prototype if that failed.
MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
Rooted<JSPropertyDescriptor> desc(cx);
if (!JS_GetPropertyDescriptorById(cx, wrapperProto, id, 0, desc.address()))
if (!JS_GetPropertyDescriptorById(cx, wrapperProto, id, 0, &desc))
return false;
*bp = !!desc.object();
return true;

View File

@ -207,7 +207,7 @@ public:
static bool resolveDOMCollectionProperty(JSContext *cx, HandleObject wrapper,
HandleObject holder, HandleId id,
JSPropertyDescriptor *desc, unsigned flags);
MutableHandle<JSPropertyDescriptor> desc, unsigned flags);
static XPCWrappedNative* getWN(JSObject *wrapper) {
return XPCWrappedNative::Get(getTargetObject(wrapper));
@ -615,7 +615,8 @@ private:
bool
XPCWrappedNativeXrayTraits::resolveDOMCollectionProperty(JSContext *cx, HandleObject wrapper,
HandleObject holder, HandleId id,
JSPropertyDescriptor *desc, unsigned flags)
MutableHandle<JSPropertyDescriptor> desc,
unsigned flags)
{
// If we are not currently resolving this id and resolveNative is called
// we don't do anything. (see defineProperty in case of shadowing is forbidden).
@ -709,7 +710,7 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
// check for those.
if (!JSID_IS_STRING(id)) {
/* Not found */
return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc.address(), flags);
return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc, flags);
}
XPCNativeInterface *iface;
@ -723,7 +724,7 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wr
} else if (!(iface = ccx.GetInterface()) ||
!(member = ccx.GetMember())) {
/* Not found */
return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc.address(), flags);
return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc, flags);
}
desc.object().set(holder);
@ -809,11 +810,11 @@ XrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,
// in the target compartment.
if (expando) {
JSAutoCompartment ac(cx, expando);
if (!JS_GetPropertyDescriptorById(cx, expando, id, 0, desc.address()))
if (!JS_GetPropertyDescriptorById(cx, expando, id, 0, desc))
return false;
}
if (desc.object()) {
if (!JS_WrapPropertyDescriptor(cx, desc.address()))
if (!JS_WrapPropertyDescriptor(cx, desc))
return false;
// Pretend the property lives on the wrapper.
desc.object().set(wrapper);
@ -853,7 +854,7 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper
}
desc.value().setObject(*obj);
mozilla::dom::FillPropertyDescriptor(desc, wrapper, true);
return JS_WrapPropertyDescriptor(cx, desc.address());
return JS_WrapPropertyDescriptor(cx, desc);
}
}
}
@ -901,7 +902,7 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper
// return non-|own| properties from Object.getOwnPropertyDescriptor if
// lookups are performed in a certain order, but we can probably live with
// that until XPCWN Xrays go away with the new DOM bindings.
return JS_GetPropertyDescriptorById(cx, holder, id, 0, desc.address());
return JS_GetPropertyDescriptorById(cx, holder, id, 0, desc);
}
bool
@ -1031,7 +1032,7 @@ DOMXrayTraits::resolveNativeProperty(JSContext *cx, HandleObject wrapper,
MutableHandle<JSPropertyDescriptor> desc, unsigned flags)
{
RootedObject obj(cx, getTargetObject(wrapper));
if (!XrayResolveNativeProperty(cx, wrapper, obj, id, desc.address()))
if (!XrayResolveNativeProperty(cx, wrapper, obj, id, desc))
return false;
NS_ASSERTION(!desc.object() || desc.object() == wrapper,
@ -1393,7 +1394,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
return false;
// Check the holder.
if (!desc.object() && !JS_GetPropertyDescriptorById(cx, holder, id, 0, desc.address()))
if (!desc.object() && !JS_GetPropertyDescriptorById(cx, holder, id, 0, desc))
return false;
if (desc.object()) {
desc.object().set(wrapper);
@ -1424,7 +1425,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
mozilla::dom::FillPropertyDescriptor(desc, wrapper,
ObjectValue(*childObj),
/* readOnly = */ true);
return JS_WrapPropertyDescriptor(cx, desc.address());
return JS_WrapPropertyDescriptor(cx, desc);
}
}
@ -1463,7 +1464,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
EnsureCompartmentPrivate(wrapper)->scope->IsXBLScope() &&
(content = do_QueryInterfaceNative(cx, wrapper)))
{
if (!nsContentUtils::LookupBindingMember(cx, content, id, desc.address()))
if (!nsContentUtils::LookupBindingMember(cx, content, id, desc))
return false;
DEBUG_CheckXBLLookup(cx, desc.address());
}
@ -1474,7 +1475,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
if (!JS_DefinePropertyById(cx, holder, id, desc.value(), desc.getter(),
desc.setter(), desc.attributes()) ||
!JS_GetPropertyDescriptorById(cx, holder, id, flags, desc.address()))
!JS_GetPropertyDescriptorById(cx, holder, id, flags, desc))
{
return false;
}
@ -1600,7 +1601,7 @@ XrayWrapper<Base, Traits>::defineProperty(JSContext *cx, HandleObject wrapper,
// Wrap the property descriptor for the target compartment.
Rooted<JSPropertyDescriptor> wrappedDesc(cx, desc);
if (!JS_WrapPropertyDescriptor(cx, wrappedDesc.address()))
if (!JS_WrapPropertyDescriptor(cx, &wrappedDesc))
return false;
// Fix up Xray waivers.