diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index a7d63b916bef..1b9d1e34605c 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -1861,7 +1861,7 @@ nsDOMClassInfo::ObjectIsNativeWrapper(JSContext* cx, JSObject* obj) } #endif - JSPropertyOp op = obj->getClass()->getProperty; + JSPropertyOp op = obj->getJSClass()->getProperty; return !!op && (op == sXPCNativeWrapperGetPropertyOp || op == sXrayWrapperPropertyHolderGetPropertyOp); } diff --git a/ipc/testshell/TestShellParent.cpp b/ipc/testshell/TestShellParent.cpp index bc95199d7a14..2f8aaed3d0ff 100644 --- a/ipc/testshell/TestShellParent.cpp +++ b/ipc/testshell/TestShellParent.cpp @@ -116,7 +116,7 @@ TestShellCommandParent::SetCallback(JSContext* aCx, JSBool TestShellCommandParent::RunCallback(const nsString& aResponse) { - NS_ENSURE_TRUE(mCallback && mCx, JS_FALSE); + NS_ENSURE_TRUE(mCallback != JSVAL_NULL && mCx, JS_FALSE); JSAutoRequest ar(mCx); diff --git a/ipc/testshell/XPCShellEnvironment.cpp b/ipc/testshell/XPCShellEnvironment.cpp index 6f38bb929dae..907b5296ddc2 100644 --- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -737,7 +737,7 @@ FullTrustSecMan::CanAccess(PRUint32 aAction, JSObject * aJSObject, nsISupports *aObj, nsIClassInfo *aClassInfo, - jsval aName, + jsid aName, void * *aPolicy) { return NS_OK; @@ -747,7 +747,7 @@ NS_IMETHODIMP FullTrustSecMan::CheckPropertyAccess(JSContext * aJSContext, JSObject * aJSObject, const char *aClassName, - jsval aProperty, + jsid aProperty, PRUint32 aAction) { return NS_OK; diff --git a/js/ipc/ObjectWrapperChild.cpp b/js/ipc/ObjectWrapperChild.cpp index 610b9f7ef104..f87ca1a82372 100644 --- a/js/ipc/ObjectWrapperChild.cpp +++ b/js/ipc/ObjectWrapperChild.cpp @@ -195,7 +195,7 @@ ObjectWrapperChild::jsval_to_JSVariant(JSContext* cx, jsval from, JSVariant* to) if (JSVAL_IS_INT(from)) *to = JSVAL_TO_INT(from); else if (JSVAL_IS_DOUBLE(from)) - *to = *JSVAL_TO_DOUBLE(from); + *to = JSVAL_TO_DOUBLE(from); else return false; return true; case JSTYPE_BOOLEAN: @@ -216,7 +216,7 @@ JSObject_from_PObjectWrapperChild(JSContext*, { const ObjectWrapperChild* owc = static_cast(from); - *to = owc ? owc->mObj : JSVAL_NULL; + *to = owc ? owc->mObj : NULL; return true; } @@ -263,7 +263,7 @@ ObjectWrapperChild::jsval_from_JSVariant(JSContext* cx, const JSVariant& from, *to = INT_TO_JSVAL(from.get_int()); return true; case JSVariant::Tdouble: - return !!JS_NewDoubleValue(cx, from.get_double(), to); + return !!JS_NewNumberValue(cx, from.get_double(), to); case JSVariant::Tbool: *to = BOOLEAN_TO_JSVAL(from.get_bool()); return true; @@ -444,7 +444,7 @@ ObjectWrapperChild::AnswerNewEnumerateInit(/* no in-parameters */ JSObject* state = JS_NewObjectWithGivenProto(cx, clasp, NULL, NULL); if (!state) return false; - AutoValueRooter tvr(cx, state); + AutoObjectRooter tvr(cx, state); for (JSObject* proto = mObj; proto; diff --git a/js/ipc/ObjectWrapperParent.cpp b/js/ipc/ObjectWrapperParent.cpp index 511c361f1ad9..2fbe3f3d4cac 100644 --- a/js/ipc/ObjectWrapperParent.cpp +++ b/js/ipc/ObjectWrapperParent.cpp @@ -230,7 +230,7 @@ ObjectWrapperParent::GetJSObject(JSContext* cx) const static ObjectWrapperParent* Unwrap(JSContext* cx, JSObject* obj) { - while (obj->getClass() != &ObjectWrapperParent::sCPOW_JSClass.base) + while (obj->getJSClass() != &ObjectWrapperParent::sCPOW_JSClass.base) if (!(obj = obj->getProto())) return NULL; @@ -275,7 +275,7 @@ ObjectWrapperParent::jsval_to_JSVariant(JSContext* cx, jsval from, if (JSVAL_IS_INT(from)) *to = JSVAL_TO_INT(from); else if (JSVAL_IS_DOUBLE(from)) - *to = *JSVAL_TO_DOUBLE(from); + *to = JSVAL_TO_DOUBLE(from); else return false; return true; case JSTYPE_BOOLEAN: @@ -310,7 +310,7 @@ ObjectWrapperParent::jsval_from_JSVariant(JSContext* cx, const JSVariant& from, *to = INT_TO_JSVAL(from.get_int()); return true; case JSVariant::Tdouble: - return !!JS_NewDoubleValue(cx, from.get_double(), to); + return !!JS_NewNumberValue(cx, from.get_double(), to); case JSVariant::Tbool: *to = BOOLEAN_TO_JSVAL(from.get_bool()); return true; @@ -379,10 +379,12 @@ jsid_from_nsString(JSContext* cx, const nsString& from, jsid* to) } static bool -jsval_to_nsString(JSContext* cx, jsval from, nsString* to) +jsval_to_nsString(JSContext* cx, jsid from, nsString* to) { JSString* str; - if ((str = JS_ValueToString(cx, from))) { + jsval idval; + if (JS_IdToValue(cx, from, &idval) && + (str = JS_ValueToString(cx, idval))) { *to = JS_GetStringChars(str); return true; } @@ -390,7 +392,7 @@ jsval_to_nsString(JSContext* cx, jsval from, nsString* to) } /*static*/ JSBool -ObjectWrapperParent::CPOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, +ObjectWrapperParent::CPOW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { CPOW_LOG(("Calling CPOW_AddProperty (%s)...", @@ -417,7 +419,7 @@ ObjectWrapperParent::CPOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, } /*static*/ JSBool -ObjectWrapperParent::CPOW_GetProperty(JSContext *cx, JSObject *obj, jsval id, +ObjectWrapperParent::CPOW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { CPOW_LOG(("Calling CPOW_GetProperty (%s)...", @@ -444,7 +446,7 @@ ObjectWrapperParent::CPOW_GetProperty(JSContext *cx, JSObject *obj, jsval id, } /*static*/ JSBool -ObjectWrapperParent::CPOW_SetProperty(JSContext *cx, JSObject *obj, jsval id, +ObjectWrapperParent::CPOW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { CPOW_LOG(("Calling CPOW_SetProperty (%s)...", @@ -473,7 +475,7 @@ ObjectWrapperParent::CPOW_SetProperty(JSContext *cx, JSObject *obj, jsval id, } /*static*/ JSBool -ObjectWrapperParent::CPOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, +ObjectWrapperParent::CPOW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { CPOW_LOG(("Calling CPOW_DelProperty (%s)...", @@ -579,7 +581,7 @@ ObjectWrapperParent::CPOW_NewEnumerate(JSContext *cx, JSObject *obj, } /*static*/ JSBool -ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, +ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp) { CPOW_LOG(("Calling CPOW_NewResolve (%s)...", @@ -605,11 +607,9 @@ ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, !JSObject_from_PObjectWrapperParent(cx, out_pobj, objp)) return JS_FALSE; - jsid interned_id; - if (*objp && - JS_ValueToId(cx, id, &interned_id)) { + if (*objp) { AutoResolveFlag arf(cx, *objp); - JS_DefinePropertyById(cx, *objp, interned_id, JSVAL_VOID, NULL, NULL, + JS_DefinePropertyById(cx, *objp, id, JSVAL_VOID, NULL, NULL, JSPROP_ENUMERATE); } return JS_TRUE; @@ -707,7 +707,7 @@ ObjectWrapperParent::CPOW_Construct(JSContext *cx, JSObject *obj, uintN argc, } /*static*/ JSBool -ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, +ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp) { CPOW_LOG(("Calling CPOW_HasInstance...")); @@ -722,7 +722,7 @@ ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSVariant in_v; - if (!jsval_to_JSVariant(cx, v, &in_v)) + if (!jsval_to_JSVariant(cx, *v, &in_v)) return JS_FALSE; return (self->Manager()->RequestRunToCompletion() && @@ -732,7 +732,7 @@ ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, } /*static*/ JSBool -ObjectWrapperParent::CPOW_Equality(JSContext *cx, JSObject *obj, jsval v, +ObjectWrapperParent::CPOW_Equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp) { CPOW_LOG(("Calling CPOW_Equality...")); @@ -743,10 +743,10 @@ ObjectWrapperParent::CPOW_Equality(JSContext *cx, JSObject *obj, jsval v, if (!self) return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_Equality"); - if (JSVAL_IS_PRIMITIVE(v)) + if (JSVAL_IS_PRIMITIVE(*v)) return JS_TRUE; - ObjectWrapperParent* other = Unwrap(cx, JSVAL_TO_OBJECT(v)); + ObjectWrapperParent* other = Unwrap(cx, JSVAL_TO_OBJECT(*v)); if (!other) return JS_TRUE; diff --git a/js/ipc/ObjectWrapperParent.h b/js/ipc/ObjectWrapperParent.h index f19cdb2b38ad..da90172b26b3 100644 --- a/js/ipc/ObjectWrapperParent.h +++ b/js/ipc/ObjectWrapperParent.h @@ -88,16 +88,16 @@ private: mutable JSObject* mObj; static JSBool - CPOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp); + CPOW_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp); static JSBool - CPOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp); + CPOW_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp); static JSBool - CPOW_GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp); + CPOW_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp); static JSBool - CPOW_SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp); + CPOW_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp); JSBool NewEnumerateInit(JSContext* cx, jsval* statep, jsid* idp); JSBool NewEnumerateNext(JSContext* cx, jsval* statep, jsid* idp); @@ -107,7 +107,7 @@ private: jsval *statep, jsid *idp); static JSBool - CPOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, + CPOW_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp); static JSBool @@ -125,10 +125,10 @@ private: jsval *rval); static JSBool - CPOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); + CPOW_HasInstance(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp); static JSBool - CPOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); + CPOW_Equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp); static bool jsval_to_JSVariant(JSContext* cx, jsval from, JSVariant* to); static bool jsval_from_JSVariant(JSContext* cx, const JSVariant& from, diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index b7166efc6cea..26532f7e80d7 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -2573,6 +2573,10 @@ obj_getOwnPropertyNames(JSContext *cx, uintN argc, Value *vp) if (!str) return false; vals[i].setString(str); + } else if (JSID_IS_ATOM(id)) { + vals[i].setString(JSID_TO_STRING(id)); + } else { + vals[i].setObject(*JSID_TO_OBJECT(id)); } } diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 01f10a3e115c..62b88ffa7f3b 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -66,6 +66,12 @@ CastAsPropertyOp(JSObject *object) return JS_DATA_TO_FUNC_PTR(PropertyOp, object); } +static inline JSPropertyOp +CastAsJSPropertyOp(JSObject *object) +{ + return JS_DATA_TO_FUNC_PTR(JSPropertyOp, object); +} + inline JSObject * CastAsObject(PropertyOp op) { diff --git a/js/src/xpconnect/wrappers/AccessCheck.cpp b/js/src/xpconnect/wrappers/AccessCheck.cpp index aa6182bcdeee..bdd9c504dc0f 100644 --- a/js/src/xpconnect/wrappers/AccessCheck.cpp +++ b/js/src/xpconnect/wrappers/AccessCheck.cpp @@ -241,7 +241,7 @@ AccessCheck::needsSystemOnlyWrapper(JSObject *obj) void AccessCheck::deny(JSContext *cx, jsid id) { - if (id == JSVID_VOID) { + if (id == JSID_VOID) { JS_ReportError(cx, "Permission denied to access object"); } else { jsval idval; @@ -273,7 +273,7 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapper, jsid id, bool set return true; // Allow } - if (id == JSVAL_VOID) { + if (id == JSID_VOID) { // This will force the caller to call us back for individual property accesses. perm = PermitPropertyAccess; return true; diff --git a/js/src/xpconnect/wrappers/FilteringWrapper.cpp b/js/src/xpconnect/wrappers/FilteringWrapper.cpp index ade00c90acca..96f071129d1b 100644 --- a/js/src/xpconnect/wrappers/FilteringWrapper.cpp +++ b/js/src/xpconnect/wrappers/FilteringWrapper.cpp @@ -66,7 +66,7 @@ static const Permission DenyAccess = JSWrapper::DenyAccess; template static bool -Filter(JSContext *cx, JSObject *wrapper, AutoValueVector &props) +Filter(JSContext *cx, JSObject *wrapper, AutoIdVector &props) { size_t w = 0; for (size_t n = 0; n < props.length(); ++n) { @@ -98,7 +98,7 @@ CheckAndReport(JSContext *cx, JSObject *wrapper, jsid id, bool set, Permission & template bool -FilteringWrapper::getOwnPropertyNames(JSContext *cx, JSObject *wrapper, AutoValueVector &props) +FilteringWrapper::getOwnPropertyNames(JSContext *cx, JSObject *wrapper, AutoIdVector &props) { return Base::getOwnPropertyNames(cx, wrapper, props) && Filter(cx, wrapper, props); @@ -106,7 +106,7 @@ FilteringWrapper::getOwnPropertyNames(JSContext *cx, JSObject *wra template bool -FilteringWrapper::enumerate(JSContext *cx, JSObject *wrapper, AutoValueVector &props) +FilteringWrapper::enumerate(JSContext *cx, JSObject *wrapper, AutoIdVector &props) { return Base::enumerate(cx, wrapper, props) && Filter(cx, wrapper, props); @@ -114,7 +114,7 @@ FilteringWrapper::enumerate(JSContext *cx, JSObject *wrapper, Auto template bool -FilteringWrapper::enumerateOwn(JSContext *cx, JSObject *wrapper, AutoValueVector &props) +FilteringWrapper::enumerateOwn(JSContext *cx, JSObject *wrapper, AutoIdVector &props) { return Base::enumerateOwn(cx, wrapper, props) && Filter(cx, wrapper, props); @@ -122,7 +122,7 @@ FilteringWrapper::enumerateOwn(JSContext *cx, JSObject *wrapper, A template bool -FilteringWrapper::iterate(JSContext *cx, JSObject *wrapper, uintN flags, jsval *vp) +FilteringWrapper::iterate(JSContext *cx, JSObject *wrapper, uintN flags, Value *vp) { // We refuse to trigger the iterator hook across chrome wrappers because // we don't know how to censor custom iterator objects. Instead we trigger @@ -136,7 +136,7 @@ bool FilteringWrapper::enter(JSContext *cx, JSObject *wrapper, jsid id, bool set) { Permission perm; - return CheckAndReport(cx, wrapper, JSVAL_VOID, set, perm) && + return CheckAndReport(cx, wrapper, JSID_VOID, set, perm) && Base::enter(cx, wrapper, id, set); } diff --git a/js/src/xpconnect/wrappers/FilteringWrapper.h b/js/src/xpconnect/wrappers/FilteringWrapper.h index 316cd704d883..11ecc9222a8c 100644 --- a/js/src/xpconnect/wrappers/FilteringWrapper.h +++ b/js/src/xpconnect/wrappers/FilteringWrapper.h @@ -48,10 +48,10 @@ class FilteringWrapper : public Base { FilteringWrapper(uintN flags); virtual ~FilteringWrapper(); - virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper, js::AutoValueVector &props); - virtual bool enumerate(JSContext *cx, JSObject *wrapper, js::AutoValueVector &props); - virtual bool enumerateOwn(JSContext *cx, JSObject *wrapper, js::AutoValueVector &props); - virtual bool iterate(JSContext *cx, JSObject *proxy, uintN flags, jsval *vp); + virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props); + virtual bool enumerate(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props); + virtual bool enumerateOwn(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props); + virtual bool iterate(JSContext *cx, JSObject *proxy, uintN flags, js::Value *vp); virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, bool set); diff --git a/js/src/xpconnect/wrappers/XrayWrapper.cpp b/js/src/xpconnect/wrappers/XrayWrapper.cpp index f6129437b380..bee0f8e1987f 100644 --- a/js/src/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/src/xpconnect/wrappers/XrayWrapper.cpp @@ -92,8 +92,8 @@ GetWrappedNative(JSObject *obj) static JSObject * GetWrappedNativeObjectFromHolder(JSObject *holder) { - NS_ASSERTION(holder->getClass() == &HolderClass, "expected a native property holder object"); - return JSVAL_TO_OBJECT(holder->getSlot(JSSLOT_WN_OBJ)); + NS_ASSERTION(holder->getJSClass() == &HolderClass, "expected a native property holder object"); + return holder->getSlot(JSSLOT_WN_OBJ).asObjectOrNull(); } // Some DOM objects have shared properties that don't have an explicit @@ -136,11 +136,11 @@ holder_set(JSContext *cx, JSObject *obj, jsid id, jsval *vp) } static bool -ResolveNativeProperty(JSContext *cx, JSObject *holder, jsval id, bool set, JSPropertyDescriptor *desc) +ResolveNativeProperty(JSContext *cx, JSObject *holder, jsid id, bool set, JSPropertyDescriptor *desc) { desc->obj = NULL; - NS_ASSERTION(holder->getClass() == &HolderClass, "expected a native property holder object"); + NS_ASSERTION(holder->getJSClass() == &HolderClass, "expected a native property holder object"); JSObject *wnObject = GetWrappedNativeObjectFromHolder(holder); XPCWrappedNative *wn = GetWrappedNative(wnObject); @@ -200,7 +200,7 @@ ResolveNativeProperty(JSContext *cx, JSObject *holder, jsval id, bool set, JSPro JS_ReportError(cx, "Failed to clone function object for native getter/setter"); return false; } - desc->getter = CastAsPropertyOp(JSVAL_TO_OBJECT(fval)); + desc->getter = CastAsJSPropertyOp(JSVAL_TO_OBJECT(fval)); desc->attrs |= JSPROP_GETTER; if (member->IsWritableAttribute()) { desc->setter = desc->getter;; @@ -269,9 +269,11 @@ wrappedJSObject_getter(JSContext *cx, JSObject *holder, jsid id, jsval *vp) template bool -XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, JSPropertyDescriptor *desc) +XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, PropertyDescriptor *desc_in) { - if (id == XPCJSRuntime::IDX_WRAPPED_JSOBJECT) { + JSPropertyDescriptor *desc = Jsvalify(desc_in); + + if (id == nsXPConnect::GetRuntimeInstance()->GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT)) { desc->obj = wrapper; desc->attrs = JSPROP_ENUMERATE|JSPROP_SHARED; desc->getter = wrappedJSObject_getter; @@ -280,7 +282,7 @@ XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid desc->value = JSVAL_VOID; return true; } - if (!Base::getPropertyDescriptor(cx, wrapper, id, desc)) { + if (!Base::getPropertyDescriptor(cx, wrapper, id, desc_in)) { return false; } if (desc->obj) @@ -290,7 +292,7 @@ XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid template bool -XrayWrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, JSPropertyDescriptor *desc) +XrayWrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, PropertyDescriptor *desc) { return getPropertyDescriptor(cx, wrapper, id, desc); } diff --git a/js/src/xpconnect/wrappers/XrayWrapper.h b/js/src/xpconnect/wrappers/XrayWrapper.h index 2d65050671fd..8f4645a2e201 100644 --- a/js/src/xpconnect/wrappers/XrayWrapper.h +++ b/js/src/xpconnect/wrappers/XrayWrapper.h @@ -54,9 +54,9 @@ class XrayWrapper : public Base { virtual ~XrayWrapper(); virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, - JSPropertyDescriptor *desc); + js::PropertyDescriptor *desc); virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, - JSPropertyDescriptor *desc); + js::PropertyDescriptor *desc); virtual bool has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp); virtual bool hasOwn(JSContext *cx, JSObject *wrapper, jsid id, bool *bp);