diff --git a/caps/src/nsSecurityManagerFactory.cpp b/caps/src/nsSecurityManagerFactory.cpp index fa1c4505c65..bf83cbc7703 100644 --- a/caps/src/nsSecurityManagerFactory.cpp +++ b/caps/src/nsSecurityManagerFactory.cpp @@ -164,20 +164,19 @@ nsSecurityNameSet::InitializeNameSet(nsIScriptContext* aScriptContext) obj = proto; JSClass *objectClass = JS_GetClass(obj); - JS::Value v; + jsval v; if (!JS_GetProperty(cx, global, "netscape", &v)) return NS_ERROR_FAILURE; - JSObject *securityObj; - if (v.isObject()) { + if (JSVAL_IS_OBJECT(v)) { /* * "netscape" property of window object exists; get the * "security" property. */ - obj = &v.toObject(); - if (!JS_GetProperty(cx, obj, "security", &v) || !v.isObject()) + obj = JSVAL_TO_OBJECT(v); + if (!JS_GetProperty(cx, obj, "security", &v) || !JSVAL_IS_OBJECT(v)) return NS_ERROR_FAILURE; - securityObj = &v.toObject(); + securityObj = JSVAL_TO_OBJECT(v); } else { /* define netscape.security object */ obj = JS_DefineObject(cx, global, "netscape", objectClass, nsnull, 0); diff --git a/content/base/crashtests/752226-1.html b/content/base/crashtests/752226-1.html deleted file mode 100644 index 9c05388ff2f..00000000000 --- a/content/base/crashtests/752226-1.html +++ /dev/null @@ -1,4 +0,0 @@ - - diff --git a/content/base/crashtests/752226-2.html b/content/base/crashtests/752226-2.html deleted file mode 100644 index 9d0aa1698e6..00000000000 --- a/content/base/crashtests/752226-2.html +++ /dev/null @@ -1,4 +0,0 @@ - - diff --git a/content/base/crashtests/crashtests.list b/content/base/crashtests/crashtests.list index ab9d5dccb8e..21e8d505769 100644 --- a/content/base/crashtests/crashtests.list +++ b/content/base/crashtests/crashtests.list @@ -107,6 +107,4 @@ load 713417.html load 713417-2.html load 715056.html load 741163-1.html -load 752226-1.html -load 752226-2.html HTTP(..) load xhr_abortinprogress.html diff --git a/content/base/src/nsDOMBlobBuilder.cpp b/content/base/src/nsDOMBlobBuilder.cpp index 21452483c76..bcd150acaf1 100644 --- a/content/base/src/nsDOMBlobBuilder.cpp +++ b/content/base/src/nsDOMBlobBuilder.cpp @@ -404,18 +404,18 @@ nsDOMBlobBuilder::GetFile(const nsAString& aName, /* [implicit_jscontext] void append (in jsval data, [optional] in DOMString endings); */ NS_IMETHODIMP -nsDOMBlobBuilder::Append(const JS::Value& aData, +nsDOMBlobBuilder::Append(const jsval& aData, const nsAString& aEndings, JSContext* aCx) { // We need to figure out what our jsval is - // Just return for null - if (aData.isNull()) - return NS_OK; - // Is it an object? - if (aData.isObject()) { - JSObject* obj = &aData.toObject(); + if (JSVAL_IS_OBJECT(aData)) { + JSObject* obj = JSVAL_TO_OBJECT(aData); + if (!obj) { + // We got passed null. Just do nothing. + return NS_OK; + } // Is it a Blob? nsCOMPtr blob = do_QueryInterface( diff --git a/content/base/src/nsDOMFile.cpp b/content/base/src/nsDOMFile.cpp index 36fecec371a..1dbc446e7c9 100644 --- a/content/base/src/nsDOMFile.cpp +++ b/content/base/src/nsDOMFile.cpp @@ -517,7 +517,7 @@ nsDOMFileFile::Initialize(nsISupports* aOwner, JSContext* aCx, JSObject* aObj, PRUint32 aArgc, - JS::Value* aArgv) + jsval* aArgv) { nsresult rv; @@ -533,13 +533,14 @@ nsDOMFileFile::Initialize(nsISupports* aOwner, // We expect to get a path to represent as a File object, // or an nsIFile nsCOMPtr file; - if (!aArgv[0].isString()) { + if (!JSVAL_IS_STRING(aArgv[0])) { // Lets see if it's an nsIFile - if (!aArgv[0].isObject()) { + if (!JSVAL_IS_OBJECT(aArgv[0])) { return NS_ERROR_UNEXPECTED; // We're not interested } - JSObject* obj = &aArgv[0].toObject(); + JSObject* obj = JSVAL_TO_OBJECT(aArgv[0]); + NS_ASSERTION(obj, "This is a bit odd"); // Is it an nsIFile file = do_QueryInterface( diff --git a/content/base/src/nsDOMParser.cpp b/content/base/src/nsDOMParser.cpp index d41db533d87..29a5023bb96 100644 --- a/content/base/src/nsDOMParser.cpp +++ b/content/base/src/nsDOMParser.cpp @@ -326,16 +326,16 @@ nsDOMParser::Init(nsIPrincipal* principal, nsIURI* documentURI, } static nsQueryInterface -JSvalToInterface(JSContext* cx, JS::Value val, nsIXPConnect* xpc, bool* wasNull) +JSvalToInterface(JSContext* cx, jsval val, nsIXPConnect* xpc, bool* wasNull) { - if (val.isNull()) { + if (val == JSVAL_NULL) { *wasNull = true; return nsQueryInterface(nsnull); } *wasNull = false; - if (val.isObject()) { - JSObject* arg = &val.toObject(); + if (JSVAL_IS_OBJECT(val)) { + JSObject* arg = JSVAL_TO_OBJECT(val); nsCOMPtr native; xpc->GetWrappedNativeOfJSObject(cx, arg, getter_AddRefs(native)); diff --git a/content/base/src/nsFrameMessageManager.cpp b/content/base/src/nsFrameMessageManager.cpp index 05b4c42351e..8d42c627f0e 100644 --- a/content/base/src/nsFrameMessageManager.cpp +++ b/content/base/src/nsFrameMessageManager.cpp @@ -453,10 +453,10 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget, jsval thisValue = JSVAL_VOID; - JS::Value funval; + jsval funval = JSVAL_VOID; if (JS_ObjectIsCallable(ctx, object)) { // If the listener is a JS function: - funval.setObject(*object); + funval = OBJECT_TO_JSVAL(object); // A small hack to get 'this' value right on content side where // messageManager is wrapped in TabChildGlobal. @@ -471,13 +471,13 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget, defaultThisValue, &thisValue, nsnull, true); } else { // If the listener is a JS object which has receiveMessage function: - if (!JS_GetProperty(ctx, object, "receiveMessage", &funval) || - !funval.isObject()) - return NS_ERROR_UNEXPECTED; - - // Check if the object is even callable. - NS_ENSURE_STATE(JS_ObjectIsCallable(ctx, &funval.toObject())); - thisValue.setObject(*object); + NS_ENSURE_STATE(JS_GetProperty(ctx, object, "receiveMessage", + &funval) && + JSVAL_IS_OBJECT(funval) && + !JSVAL_IS_NULL(funval)); + JSObject* funobject = JSVAL_TO_OBJECT(funval); + NS_ENSURE_STATE(JS_ObjectIsCallable(ctx, funobject)); + thisValue = OBJECT_TO_JSVAL(object); } jsval rval = JSVAL_VOID; diff --git a/content/base/src/nsWebSocket.cpp b/content/base/src/nsWebSocket.cpp index 2db63c5dac0..f9a8921a5e4 100644 --- a/content/base/src/nsWebSocket.cpp +++ b/content/base/src/nsWebSocket.cpp @@ -562,7 +562,7 @@ nsWebSocket::Initialize(nsISupports* aOwner, JSContext* aContext, JSObject* aObject, PRUint32 aArgc, - JS::Value* aArgv) + jsval* aArgv) { NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread"); nsAutoString urlParam; @@ -608,10 +608,11 @@ nsWebSocket::Initialize(nsISupports* aOwner, nsTArray protocolArray; if (aArgc == 2) { - if (aArgv[1].isObject() && - JS_IsArrayObject(aContext, &aArgv[1].toObject())) { - JSObject* jsobj = &aArgv[1].toObject(); + JSObject *jsobj; + if (JSVAL_IS_OBJECT(aArgv[1]) && + (jsobj = JSVAL_TO_OBJECT(aArgv[1])) && + JS_IsArrayObject(aContext, jsobj)) { uint32_t len; JS_GetArrayLength(aContext, jsobj, &len); diff --git a/content/base/test/chrome/Makefile.in b/content/base/test/chrome/Makefile.in index 1736ca1a952..297bd18778e 100644 --- a/content/base/test/chrome/Makefile.in +++ b/content/base/test/chrome/Makefile.in @@ -73,8 +73,6 @@ _CHROME_FILES = \ test_bug599295.html \ test_bug650776.html \ test_bug650784.html \ - test_bug752226-3.xul \ - test_bug752226-4.xul \ $(NULL) libs:: $(_TEST_FILES) diff --git a/content/base/test/chrome/test_bug752226-3.xul b/content/base/test/chrome/test_bug752226-3.xul deleted file mode 100644 index 83a2e88cb8d..00000000000 --- a/content/base/test/chrome/test_bug752226-3.xul +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - diff --git a/content/base/test/chrome/test_bug752226-4.xul b/content/base/test/chrome/test_bug752226-4.xul deleted file mode 100644 index 10bf24d908c..00000000000 --- a/content/base/test/chrome/test_bug752226-4.xul +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - diff --git a/content/canvas/src/CustomQS_WebGL.h b/content/canvas/src/CustomQS_WebGL.h index cab9e0b9aef..2a5ac477166 100644 --- a/content/canvas/src/CustomQS_WebGL.h +++ b/content/canvas/src/CustomQS_WebGL.h @@ -193,14 +193,14 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, unsigned argc, jsval *vp) if (argc < 6 || argc == 7 || argc == 8) return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS); - JS::Value* argv = JS_ARGV(cx, vp); + jsval *argv = JS_ARGV(cx, vp); // arguments common to all cases GET_UINT32_ARG(argv0, 0); GET_INT32_ARG(argv1, 1); GET_UINT32_ARG(argv2, 2); - if (argc > 5 && argv[5].isObject()) { + if (argc > 5 && !JSVAL_IS_PRIMITIVE(argv[5])) { // implement the variants taking a DOMElement as argv[5] GET_UINT32_ARG(argv3, 3); GET_UINT32_ARG(argv4, 4); @@ -210,7 +210,7 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, unsigned argc, jsval *vp) return false; } rv = NS_OK; - } else if (argc > 8 && argv[8].isObjectOrNull()) { + } else if (argc > 8 && JSVAL_IS_OBJECT(argv[8])) { // here, we allow null ! // implement the variants taking a buffer/array as argv[8] GET_INT32_ARG(argv3, 3); @@ -219,7 +219,7 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, unsigned argc, jsval *vp) GET_UINT32_ARG(argv6, 6); GET_UINT32_ARG(argv7, 7); - JSObject* argv8 = argv[8].toObjectOrNull(); + JSObject *argv8 = JSVAL_TO_OBJECT(argv[8]); // then try to grab either a js::TypedArray, or null if (argv8 == nsnull) { diff --git a/content/html/content/src/nsHTMLCanvasElement.cpp b/content/html/content/src/nsHTMLCanvasElement.cpp index d9fee16cd1b..bbc72bd48ed 100644 --- a/content/html/content/src/nsHTMLCanvasElement.cpp +++ b/content/html/content/src/nsHTMLCanvasElement.cpp @@ -498,7 +498,7 @@ nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId, NS_IMETHODIMP nsHTMLCanvasElement::GetContext(const nsAString& aContextId, - const JS::Value& aContextOptions, + const jsval& aContextOptions, nsISupports **aContext) { nsresult rv; @@ -521,51 +521,52 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId, return NS_ERROR_FAILURE; } - // note: if any contexts end up supporting something other - // than objects, e.g. plain strings, then we'll need to expand - // this to know how to create nsISupportsStrings etc. - nsCOMPtr contextProps; - if (aContextOptions.isObject()) + if (!JSVAL_IS_NULL(aContextOptions) && + !JSVAL_IS_VOID(aContextOptions)) { JSContext *cx = nsContentUtils::GetCurrentJSContext(); - contextProps = do_CreateInstance("@mozilla.org/hash-property-bag;1"); + // note: if any contexts end up supporting something other + // than objects, e.g. plain strings, then we'll need to expand + // this to know how to create nsISupportsStrings etc. + if (JSVAL_IS_OBJECT(aContextOptions)) { + contextProps = do_CreateInstance("@mozilla.org/hash-property-bag;1"); - JSObject *opts = &aContextOptions.toObject(); - JS::AutoIdArray props(cx, JS_Enumerate(cx, opts)); - for (size_t i = 0; !!props && i < props.length(); ++i) { - jsid propid = props[i]; - jsval propname, propval; - if (!JS_IdToValue(cx, propid, &propname) || - !JS_GetPropertyById(cx, opts, propid, &propval)) { - continue; - } + JSObject *opts = JSVAL_TO_OBJECT(aContextOptions); + JS::AutoIdArray props(cx, JS_Enumerate(cx, opts)); + for (size_t i = 0; !!props && i < props.length(); ++i) { + jsid propid = props[i]; + jsval propname, propval; + if (!JS_IdToValue(cx, propid, &propname) || + !JS_GetPropertyById(cx, opts, propid, &propval)) { + continue; + } - JSString *propnameString = JS_ValueToString(cx, propname); - nsDependentJSString pstr; - if (!propnameString || !pstr.init(cx, propnameString)) { - mCurrentContext = nsnull; - return NS_ERROR_FAILURE; - } - - if (JSVAL_IS_BOOLEAN(propval)) { - contextProps->SetPropertyAsBool(pstr, JSVAL_TO_BOOLEAN(propval)); - } else if (JSVAL_IS_INT(propval)) { - contextProps->SetPropertyAsInt32(pstr, JSVAL_TO_INT(propval)); - } else if (JSVAL_IS_DOUBLE(propval)) { - contextProps->SetPropertyAsDouble(pstr, JSVAL_TO_DOUBLE(propval)); - } else if (JSVAL_IS_STRING(propval)) { - JSString *propvalString = JS_ValueToString(cx, propval); - nsDependentJSString vstr; - if (!propvalString || !vstr.init(cx, propvalString)) { + JSString *propnameString = JS_ValueToString(cx, propname); + nsDependentJSString pstr; + if (!propnameString || !pstr.init(cx, propnameString)) { mCurrentContext = nsnull; return NS_ERROR_FAILURE; } - contextProps->SetPropertyAsAString(pstr, vstr); - } + if (JSVAL_IS_BOOLEAN(propval)) { + contextProps->SetPropertyAsBool(pstr, JSVAL_TO_BOOLEAN(propval)); + } else if (JSVAL_IS_INT(propval)) { + contextProps->SetPropertyAsInt32(pstr, JSVAL_TO_INT(propval)); + } else if (JSVAL_IS_DOUBLE(propval)) { + contextProps->SetPropertyAsDouble(pstr, JSVAL_TO_DOUBLE(propval)); + } else if (JSVAL_IS_STRING(propval)) { + JSString *propvalString = JS_ValueToString(cx, propval); + nsDependentJSString vstr; + if (!propvalString || !vstr.init(cx, propvalString)) { + mCurrentContext = nsnull; + return NS_ERROR_FAILURE; + } + contextProps->SetPropertyAsAString(pstr, vstr); + } + } } } diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index a575abeb9f3..d243261f2c2 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -2087,19 +2087,19 @@ CreateExceptionFromResult(JSContext *cx, nsresult aResult) return NS_ERROR_FAILURE; } - JS::Value jv; + jsval jv; nsCOMPtr holder; rv = WrapNative(cx, ::JS_GetGlobalObject(cx), exception, &NS_GET_IID(nsIException), false, &jv, getter_AddRefs(holder)); - if (NS_FAILED(rv) || jv.isNull()) { + if (NS_FAILED(rv) || JSVAL_IS_NULL(jv)) { return NS_ERROR_FAILURE; } JSAutoEnterCompartment ac; - if (jv.isObject()) { - if (!ac.enter(cx, &jv.toObject())) { + if (JSVAL_IS_OBJECT(jv)) { + if (!ac.enter(cx, JSVAL_TO_OBJECT(jv))) { return NS_ERROR_UNEXPECTED; } } @@ -6492,23 +6492,26 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx, JSObject *proto = nsnull; if (class_parent_name) { + jsval val; + JSAutoEnterCompartment ac; if (!ac.enter(cx, winobj)) { return NS_ERROR_UNEXPECTED; } - JS::Value val; - if (!JS_LookupProperty(cx, winobj, CutPrefix(class_parent_name), &val)) { + if (!::JS_LookupProperty(cx, winobj, CutPrefix(class_parent_name), &val)) { return NS_ERROR_UNEXPECTED; } - if (val.isObject()) { - if (!JS_LookupProperty(cx, &val.toObject(), "prototype", &val)) { + JSObject *tmp = JSVAL_IS_OBJECT(val) ? JSVAL_TO_OBJECT(val) : nsnull; + + if (tmp) { + if (!::JS_LookupProperty(cx, tmp, "prototype", &val)) { return NS_ERROR_UNEXPECTED; } - if (val.isObject()) { - proto = &val.toObject(); + if (JSVAL_IS_OBJECT(val)) { + proto = JSVAL_TO_OBJECT(val); } } } @@ -8953,9 +8956,8 @@ nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp) // If we are called via document.all(id) instead of document.all.item(i) or // another method, use the document.all callee object as self. JSObject *self; - JS::Value callee = JS_CALLEE(cx, vp); - if (callee.isObject() && - JS_GetClass(&callee.toObject()) == &sHTMLDocumentAllClass) { + if (JSVAL_IS_OBJECT(JS_CALLEE(cx, vp)) && + ::JS_GetClass(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp))) == &sHTMLDocumentAllClass) { self = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)); } else { self = JS_THIS_OBJECT(cx, vp); @@ -8999,7 +9001,7 @@ PrivateToFlags(void *priv) JSBool nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj, - jsid id, JS::Value *vp) + jsid id, jsval *vp) { if (id != nsDOMClassInfo::sAll_id) { return JS_TRUE; @@ -9022,12 +9024,12 @@ nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj, // or it was not being resolved with a qualified name. Claim that // document.all is undefined. - vp->setUndefined(); + *vp = JSVAL_VOID; } else { // document.all is not being detected, and it resolved with a // qualified name. Expose the document.all collection. - if (!vp->isObjectOrNull()) { + if (!JSVAL_IS_OBJECT(*vp)) { // First time through, create the collection, and set the // document as its private nsISupports data. nsresult rv; @@ -9049,7 +9051,7 @@ nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj, doc.forget(); - vp->setObject(*all); + *vp = OBJECT_TO_JSVAL(all); } } @@ -9493,20 +9495,25 @@ nsHTMLSelectElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper, // static nsresult -nsHTMLSelectElementSH::SetOption(JSContext *cx, JS::Value *vp, PRUint32 aIndex, +nsHTMLSelectElementSH::SetOption(JSContext *cx, jsval *vp, PRUint32 aIndex, nsIDOMHTMLOptionsCollection *aOptCollection) { JSAutoRequest ar(cx); // vp must refer to an object - if (!vp->isObject()) { + if (!JSVAL_IS_OBJECT(*vp) && !::JS_ConvertValue(cx, *vp, JSTYPE_OBJECT, vp)) { return NS_ERROR_UNEXPECTED; } - nsCOMPtr new_option = do_QueryWrapper(cx, &vp->toObject()); - if (!new_option) { - // Someone is trying to set an option to a non-option object. - return NS_ERROR_UNEXPECTED; + nsCOMPtr new_option; + + if (!JSVAL_IS_NULL(*vp)) { + new_option = do_QueryWrapper(cx, JSVAL_TO_OBJECT(*vp)); + if (!new_option) { + // Someone is trying to set an option to a non-option object. + + return NS_ERROR_UNEXPECTED; + } } return aOptCollection->SetOption(aIndex, new_option); diff --git a/dom/src/json/nsJSON.cpp b/dom/src/json/nsJSON.cpp index 7d97f77a6ea..88c5eec05aa 100644 --- a/dom/src/json/nsJSON.cpp +++ b/dom/src/json/nsJSON.cpp @@ -204,7 +204,7 @@ WriteCallback(const jschar *buf, uint32_t len, void *data) } NS_IMETHODIMP -nsJSON::EncodeFromJSVal(JS::Value *value, JSContext *cx, nsAString &result) +nsJSON::EncodeFromJSVal(jsval *value, JSContext *cx, nsAString &result) { result.Truncate(); @@ -212,9 +212,9 @@ nsJSON::EncodeFromJSVal(JS::Value *value, JSContext *cx, nsAString &result) JSAutoRequest ar(cx); JSAutoEnterCompartment ac; + JSObject *obj; nsIScriptSecurityManager *ssm = nsnull; - if (value->isObject()) { - JSObject *obj = &value->toObject(); + if (JSVAL_IS_OBJECT(*value) && (obj = JSVAL_TO_OBJECT(*value))) { if (!ac.enter(cx, obj)) { return NS_ERROR_FAILURE; } @@ -254,11 +254,14 @@ nsJSON::EncodeInternal(JSContext* cx, const JS::Value& aValue, nsJSONWriter* wri // Backward compatibility: // nsIJSON does not allow to serialize anything other than objects - if (!aValue.isObject()) { + if (!JSVAL_IS_OBJECT(aValue)) { return NS_ERROR_INVALID_ARG; } - JSObject* obj = &aValue.toObject(); + JSObject* obj = JSVAL_TO_OBJECT(aValue); + if (!obj) { + return NS_ERROR_INVALID_ARG; + } JS::Value val = aValue; diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index d8f7c9f9822..67620219915 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -1846,7 +1846,7 @@ WorkerRunnable::NotifyScriptExecutedIfNeeded() const struct WorkerPrivate::TimeoutInfo { TimeoutInfo() - : mTimeoutVal(JS::UndefinedValue()), mLineNumber(0), mId(0), mIsInterval(false), + : mTimeoutVal(JSVAL_VOID), mLineNumber(0), mId(0), mIsInterval(false), mCanceled(false) { MOZ_COUNT_CTOR(mozilla::dom::workers::WorkerPrivate::TimeoutInfo); @@ -1867,7 +1867,7 @@ struct WorkerPrivate::TimeoutInfo return mTargetTime < aOther.mTargetTime; } - JS::Value mTimeoutVal; + jsval mTimeoutVal; nsTArray mExtraArgVals; mozilla::TimeStamp mTargetTime; mozilla::TimeDuration mInterval; @@ -3619,11 +3619,11 @@ WorkerPrivate::SetTimeout(JSContext* aCx, unsigned aArgc, jsval* aVp, mNextTimeoutId = 1; } - JS::Value* argv = JS_ARGV(aCx, aVp); + jsval* argv = JS_ARGV(aCx, aVp); // Take care of the main argument. - if (argv[0].isObject()) { - if (JS_ObjectIsCallable(aCx, &argv[0].toObject())) { + if (JSVAL_IS_OBJECT(argv[0])) { + if (JS_ObjectIsCallable(aCx, JSVAL_TO_OBJECT(argv[0]))) { newInfo->mTimeoutVal = argv[0]; } else { @@ -3631,10 +3631,10 @@ WorkerPrivate::SetTimeout(JSContext* aCx, unsigned aArgc, jsval* aVp, if (!timeoutStr) { return false; } - newInfo->mTimeoutVal.setString(timeoutStr); + newInfo->mTimeoutVal = STRING_TO_JSVAL(timeoutStr); } } - else if (argv[0].isString()) { + else if (JSVAL_IS_STRING(argv[0])) { newInfo->mTimeoutVal = argv[0]; } else { @@ -3651,7 +3651,7 @@ WorkerPrivate::SetTimeout(JSContext* aCx, unsigned aArgc, jsval* aVp, } newInfo->mInterval = TimeDuration::FromMilliseconds(intervalMS); - if (aArgc > 2 && newInfo->mTimeoutVal.isObject()) { + if (aArgc > 2 && JSVAL_IS_OBJECT(newInfo->mTimeoutVal)) { nsTArray extraArgVals(aArgc - 2); for (unsigned index = 2; index < aArgc; index++) { extraArgVals.AppendElement(argv[index]); @@ -3662,7 +3662,7 @@ WorkerPrivate::SetTimeout(JSContext* aCx, unsigned aArgc, jsval* aVp, newInfo->mTargetTime = TimeStamp::Now() + newInfo->mInterval; - if (newInfo->mTimeoutVal.isString()) { + if (JSVAL_IS_STRING(newInfo->mTimeoutVal)) { const char* filenameChars; PRUint32 lineNumber; if (nsJSUtils::GetCallingLocation(aCx, &filenameChars, &lineNumber)) { @@ -3786,8 +3786,8 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx) // JS_ReportPendingException returns false (i.e. uncatchable exception) then // break out of the loop. - if (info->mTimeoutVal.isString()) { - JSString* expression = info->mTimeoutVal.toString(); + if (JSVAL_IS_STRING(info->mTimeoutVal)) { + JSString* expression = JSVAL_TO_STRING(info->mTimeoutVal); size_t stringLength; const jschar* string = JS_GetStringCharsAndLength(aCx, expression, diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index e1ada88c9ce..92bfa49a303 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -297,18 +297,19 @@ private: static JSBool UnwrapErrorEvent(JSContext* aCx, unsigned aArgc, jsval* aVp) { + JS_ASSERT(JSVAL_IS_OBJECT(JS_CALLEE(aCx, aVp))); JS_ASSERT(aArgc == 1); - JS_ASSERT((JS_ARGV(aCx, aVp)[0]).isObject()); + JS_ASSERT(JSVAL_IS_OBJECT(JS_ARGV(aCx, aVp)[0])); - JSObject* wrapper = &JS_CALLEE(aCx, aVp).toObject(); + JSObject* wrapper = JSVAL_TO_OBJECT(JS_CALLEE(aCx, aVp)); JS_ASSERT(JS_ObjectIsFunction(aCx, wrapper)); jsval scope = js::GetFunctionNativeReserved(wrapper, SLOT_wrappedScope); jsval listener = js::GetFunctionNativeReserved(wrapper, SLOT_wrappedFunction); - JS_ASSERT(scope.isObject()); + JS_ASSERT(JSVAL_IS_OBJECT(scope)); - JSObject* event = &JS_ARGV(aCx, aVp)[0].toObject(); + JSObject* event = JSVAL_TO_OBJECT(JS_ARGV(aCx, aVp)[0]); jsval argv[3] = { JSVAL_VOID, JSVAL_VOID, JSVAL_VOID }; if (!JS_GetProperty(aCx, event, "message", &argv[0]) || diff --git a/js/jsd/jsd_val.c b/js/jsd/jsd_val.c index 31b2299dc1b..6d51db663a1 100644 --- a/js/jsd/jsd_val.c +++ b/js/jsd/jsd_val.c @@ -51,7 +51,7 @@ void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval) if(!JS_CLIST_IS_EMPTY(&jsdval->props)) { JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS)); - JS_ASSERT(!JSVAL_IS_PRIMITIVE(jsdval->val)); + JS_ASSERT(JSVAL_IS_OBJECT(jsdval->val)); } if(jsdval->proto) @@ -87,7 +87,7 @@ void JSD_ASSERT_VALID_PROPERTY(JSDProperty* jsdprop) JSBool jsd_IsValueObject(JSDContext* jsdc, JSDValue* jsdval) { - return !JSVAL_IS_PRIMITIVE(jsdval->val) || JSVAL_IS_NULL(jsdval->val); + return JSVAL_IS_OBJECT(jsdval->val); } JSBool @@ -449,7 +449,7 @@ static JSBool _buildProps(JSDContext* jsdc, JSDValue* jsdval) JS_ASSERT(JS_CLIST_IS_EMPTY(&jsdval->props)); JS_ASSERT(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS))); - JS_ASSERT(!JSVAL_IS_PRIMITIVE(jsdval->val)); + JS_ASSERT(JSVAL_IS_OBJECT(jsdval->val)); if(JSVAL_IS_PRIMITIVE(jsdval->val)) return JS_FALSE; @@ -675,16 +675,16 @@ jsd_GetValueFunction(JSDContext* jsdc, JSDValue* jsdval) { JSObject *obj; JSFunction *fun; - JSCrossCompartmentCall *call = NULL; - if (JSVAL_IS_PRIMITIVE(jsdval->val)) + if (!JSVAL_IS_OBJECT(jsdval->val)) return NULL; + if(!(obj = JSVAL_TO_OBJECT(jsdval->val))) + return NULL; + obj = JS_UnwrapObject(obj); - obj = JS_UnwrapObject(JSVAL_TO_OBJECT(jsdval->val)); call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj); if (!call) return NULL; - fun = JS_ValueToFunction(jsdc->dumbContext, OBJECT_TO_JSVAL(obj)); JS_LeaveCrossCompartmentCall(call); @@ -702,9 +702,10 @@ jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval) JSObject* proto; JS_ASSERT(!jsdval->proto); SET_BIT_FLAG(jsdval->flags, GOT_PROTO); - if(JSVAL_IS_PRIMITIVE(jsdval->val)) + if(!JSVAL_IS_OBJECT(jsdval->val)) + return NULL; + if(!(obj = JSVAL_TO_OBJECT(jsdval->val))) return NULL; - obj = JSVAL_TO_OBJECT(jsdval->val); proto = JS_GetPrototype(obj); if(!proto) return NULL; @@ -726,9 +727,10 @@ jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval) JSObject* parent; JS_ASSERT(!jsdval->parent); SET_BIT_FLAG(jsdval->flags, GOT_PARENT); - if(JSVAL_IS_PRIMITIVE(jsdval->val)) + if(!JSVAL_IS_OBJECT(jsdval->val)) + return NULL; + if(!(obj = JSVAL_TO_OBJECT(jsdval->val))) return NULL; - obj = JSVAL_TO_OBJECT(jsdval->val); JS_BeginRequest(jsdc->dumbContext); call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj); if(!call) { @@ -760,9 +762,10 @@ jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval) JSObject* ctor; JS_ASSERT(!jsdval->ctor); SET_BIT_FLAG(jsdval->flags, GOT_CTOR); - if(JSVAL_IS_PRIMITIVE(jsdval->val)) + if(!JSVAL_IS_OBJECT(jsdval->val)) + return NULL; + if(!(obj = JSVAL_TO_OBJECT(jsdval->val))) return NULL; - obj = JSVAL_TO_OBJECT(jsdval->val); proto = JS_GetPrototype(obj); if(!proto) return NULL; @@ -791,9 +794,11 @@ jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval) jsval val = jsdval->val; JSCrossCompartmentCall *call = NULL; - if(!jsdval->className && !JSVAL_IS_PRIMITIVE(val)) + if(!jsdval->className && JSVAL_IS_OBJECT(val)) { - JSObject* obj = JSVAL_TO_OBJECT(val); + JSObject* obj; + if(!(obj = JSVAL_TO_OBJECT(val))) + return NULL; JS_BeginRequest(jsdc->dumbContext); call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj); if(!call) { diff --git a/js/jsd/jsd_xpc.cpp b/js/jsd/jsd_xpc.cpp index ef314ecb222..d94b78b3c1a 100644 --- a/js/jsd/jsd_xpc.cpp +++ b/js/jsd/jsd_xpc.cpp @@ -2240,7 +2240,7 @@ jsdValue::GetJsType (PRUint32 *_rval) *_rval = TYPE_VOID; else if (JSD_IsValueFunction (mCx, mValue)) *_rval = TYPE_FUNCTION; - else if (!JSVAL_IS_PRIMITIVE(val)) + else if (JSVAL_IS_OBJECT(val)) *_rval = TYPE_OBJECT; else NS_ASSERTION (0, "Value has no discernible type."); diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index a19172310dd..6aa55909cea 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -3633,8 +3633,8 @@ PointerType::ConstructData(JSContext* cx, jsval* argv = JS_ARGV(cx, vp); JSObject* baseObj = PointerType::GetBaseType(obj); bool looksLikeClosure = CType::GetTypeCode(baseObj) == TYPE_function && - argv[0].isObject() && - JS_ObjectIsCallable(cx, &argv[0].toObject()); + JSVAL_IS_OBJECT(argv[0]) && + JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(argv[0])); // // Case 2 - Initialized pointer @@ -3656,9 +3656,7 @@ PointerType::ConstructData(JSContext* cx, // wish to pass the third argument. JSObject* thisObj = NULL; if (argc >= 2) { - if (JSVAL_IS_NULL(argv[1])) { - thisObj = NULL; - } else if (!JSVAL_IS_PRIMITIVE(argv[1])) { + if (JSVAL_IS_OBJECT(argv[1])) { thisObj = JSVAL_TO_OBJECT(argv[1]); } else if (!JS_ValueToObject(cx, argv[1], &thisObj)) { return JS_FALSE; @@ -3698,7 +3696,7 @@ PointerType::TargetTypeGetter(JSContext* cx, } *vp = JS_GetReservedSlot(obj, SLOT_TARGET_T); - JS_ASSERT(vp->isObject()); + JS_ASSERT(JSVAL_IS_OBJECT(*vp)); return JS_TRUE; } @@ -6532,12 +6530,12 @@ CDataFinalizer::Construct(JSContext* cx, unsigned argc, jsval *vp) } jsval* argv = JS_ARGV(cx, vp); - JS::Value valCodePtr = argv[1]; - if (!valCodePtr.isObject()) { + jsval valCodePtr = argv[1]; + if (!JSVAL_IS_OBJECT(valCodePtr) || JSVAL_IS_NULL(valCodePtr)) { return TypeError(cx, "_a CData object_ of a function pointer type", valCodePtr); } - JSObject *objCodePtr = &valCodePtr.toObject(); + JSObject *objCodePtr = JSVAL_TO_OBJECT(valCodePtr); //Note: Using a custom argument formatter here would be awkward (requires //a destructor just to uninstall the formatter). diff --git a/js/src/jsapi-tests/testBindCallable.cpp b/js/src/jsapi-tests/testBindCallable.cpp index 70ae0ef8b13..90d7b43299f 100644 --- a/js/src/jsapi-tests/testBindCallable.cpp +++ b/js/src/jsapi-tests/testBindCallable.cpp @@ -4,19 +4,19 @@ BEGIN_TEST(test_BindCallable) { jsval v; EVAL("({ somename : 1717 })", &v); - CHECK(v.isObject()); + CHECK(JSVAL_IS_OBJECT(v)); jsval func; EVAL("(function() { return this.somename; })", &func); - CHECK(func.isObject()); + CHECK(JSVAL_IS_OBJECT(func)); JSObject* newCallable = JS_BindCallable(cx, JSVAL_TO_OBJECT(func), - JSVAL_TO_OBJECT(v)); + JSVAL_TO_OBJECT(v)); CHECK(newCallable); jsval retval; bool called = JS_CallFunctionValue(cx, NULL, OBJECT_TO_JSVAL(newCallable), - 0, NULL, &retval); + 0, NULL, &retval); CHECK(called); CHECK(JSVAL_IS_INT(retval)); diff --git a/js/src/jsapi-tests/testConservativeGC.cpp b/js/src/jsapi-tests/testConservativeGC.cpp index 5201ec219f5..cccc131bf49 100644 --- a/js/src/jsapi-tests/testConservativeGC.cpp +++ b/js/src/jsapi-tests/testConservativeGC.cpp @@ -6,7 +6,7 @@ BEGIN_TEST(testConservativeGC) { jsval v2; EVAL("({foo: 'bar'});", &v2); - CHECK(v2.isObject()); + CHECK(JSVAL_IS_OBJECT(v2)); char objCopy[sizeof(JSObject)]; js_memcpy(&objCopy, JSVAL_TO_OBJECT(v2), sizeof(JSObject)); @@ -18,7 +18,7 @@ BEGIN_TEST(testConservativeGC) jsval tmp; EVAL("({foo2: 'bar2'});", &tmp); - CHECK(tmp.isObject()); + CHECK(JSVAL_IS_OBJECT(tmp)); JSObject *obj2 = JSVAL_TO_OBJECT(tmp); char obj2Copy[sizeof(JSObject)]; js_memcpy(&obj2Copy, obj2, sizeof(JSObject)); diff --git a/js/src/jsapi-tests/testLookup.cpp b/js/src/jsapi-tests/testLookup.cpp index 7a13e4ab5ba..1ecd5b1172f 100644 --- a/js/src/jsapi-tests/testLookup.cpp +++ b/js/src/jsapi-tests/testLookup.cpp @@ -24,8 +24,8 @@ BEGIN_TEST(testLookup_bug522590) // This lookup must not return an internal function object. jsvalRoot r(cx); CHECK(JS_LookupProperty(cx, xobj, "f", r.addr())); - CHECK(r.value().isObject()); - JSObject *funobj = &r.value().toObject(); + CHECK(JSVAL_IS_OBJECT(r)); + JSObject *funobj = JSVAL_TO_OBJECT(r); CHECK(funobj->isFunction()); CHECK(!js::IsInternalFunctionObject(funobj)); diff --git a/js/src/jsapi-tests/testTrap.cpp b/js/src/jsapi-tests/testTrap.cpp index 08fd40b6c51..91b4debd758 100644 --- a/js/src/jsapi-tests/testTrap.cpp +++ b/js/src/jsapi-tests/testTrap.cpp @@ -36,7 +36,7 @@ BEGIN_TEST(testTrap_gc) // execute jsvalRoot v2(cx); CHECK(JS_ExecuteScript(cx, global, script, v2.addr())); - CHECK(v2.value().isObject()); + CHECK(JSVAL_IS_OBJECT(v2)); CHECK_EQUAL(emptyTrapCallCount, 0); // Enable debug mode diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 9044d711ba2..90f6d3394f3 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -2696,14 +2696,18 @@ EvalInFrame(JSContext *cx, unsigned argc, jsval *vp) } static JSBool -ShapeOf(JSContext *cx, unsigned argc, JS::Value *vp) +ShapeOf(JSContext *cx, unsigned argc, jsval *vp) { - JS::Value v; - if (argc < 1 || !((v = JS_ARGV(cx, vp)[0]).isObject())) { + jsval v; + if (argc < 1 || !JSVAL_IS_OBJECT(v = JS_ARGV(cx, vp)[0])) { JS_ReportError(cx, "shapeOf: object expected"); return JS_FALSE; } - JSObject *obj = &v.toObject(); + JSObject *obj = JSVAL_TO_OBJECT(v); + if (!obj) { + *vp = JSVAL_ZERO; + return JS_TRUE; + } return JS_NewNumberValue(cx, (double) ((uintptr_t)obj->lastProperty() >> 3), vp); } @@ -3852,13 +3856,13 @@ Help(JSContext *cx, unsigned argc, jsval *vp) jsval v; if (!JS_LookupPropertyById(cx, global, ida[i], &v)) return false; - if (!JSVAL_IS_PRIMITIVE(v) && !PrintHelp(cx, JSVAL_TO_OBJECT(v))) + if (JSVAL_IS_OBJECT(v) && !PrintHelp(cx, JSVAL_TO_OBJECT(v))) return false; } } else { jsval *argv = JS_ARGV(cx, vp); for (unsigned i = 0; i < argc; i++) { - if (!JSVAL_IS_PRIMITIVE(argv[i]) && !PrintHelp(cx, JSVAL_TO_OBJECT(argv[i]))) + if (JSVAL_IS_OBJECT(argv[i]) && !PrintHelp(cx, JSVAL_TO_OBJECT(argv[i]))) return false; } } diff --git a/js/src/shell/jsheaptools.cpp b/js/src/shell/jsheaptools.cpp index 5e0158f000a..686ebbe0055 100644 --- a/js/src/shell/jsheaptools.cpp +++ b/js/src/shell/jsheaptools.cpp @@ -516,20 +516,21 @@ ReferenceFinder::addReferrer(jsval referrer, Path *path) Root referrerRoot(context, &referrer); /* Find the property of the results object named |pathName|. */ - JS::Value v; + jsval v; if (!JS_GetProperty(context, result, pathName, &v)) return false; - if (v.isUndefined()) { + if (JSVAL_IS_VOID(v)) { /* Create an array to accumulate referents under this path. */ JSObject *array = JS_NewArrayObject(context, 1, &referrer); if (!array) return false; - v.setObject(*array); + v = OBJECT_TO_JSVAL(array); return !!JS_SetProperty(context, result, pathName, &v); } /* The property's value had better be an array. */ - RootedVarObject array(context, &v.toObject()); + JS_ASSERT(JSVAL_IS_OBJECT(v) && !JSVAL_IS_NULL(v)); + RootedVarObject array(context, JSVAL_TO_OBJECT(v)); JS_ASSERT(JS_IsArrayObject(context, array)); /* Append our referrer to this array. */ @@ -560,8 +561,8 @@ FindReferences(JSContext *cx, unsigned argc, jsval *vp) return false; } - JS::Value target = JS_ARGV(cx, vp)[0]; - if (!target.isObject()) { + jsval target = JS_ARGV(cx, vp)[0]; + if (!JSVAL_IS_OBJECT(target) || JSVAL_IS_NULL(target)) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_UNEXPECTED_TYPE, "argument", "not an object"); return false; @@ -574,7 +575,7 @@ FindReferences(JSContext *cx, unsigned argc, jsval *vp) /* Given the reversed map, find the referents of target. */ ReferenceFinder finder(cx, reverser); - JSObject *references = finder.findReferences(RootedVarObject(cx, &target.toObject())); + JSObject *references = finder.findReferences(RootedVarObject(cx, JSVAL_TO_OBJECT(target))); if (!references) return false; diff --git a/js/src/shell/jsworkers.cpp b/js/src/shell/jsworkers.cpp index 32a4cb8d56c..3317cf6e59a 100644 --- a/js/src/shell/jsworkers.cpp +++ b/js/src/shell/jsworkers.cpp @@ -971,7 +971,7 @@ class ErrorEvent : public Event public: static ErrorEvent *create(JSContext *cx, Worker *child) { JSString *data = NULL; - JS::Value exc; + jsval exc; if (JS_GetPendingException(cx, &exc)) { AutoValueRooter tvr(cx, exc); JS_ClearPendingException(cx); @@ -979,12 +979,12 @@ class ErrorEvent : public Event // Determine what error message to put in the error event. // If exc.message is a string, use that; otherwise use String(exc). // (This is a little different from what web workers do.) - if (exc.isObject()) { - JS::Value msg; - if (!JS_GetProperty(cx, &exc.toObject(), "message", &msg)) + if (JSVAL_IS_OBJECT(exc)) { + jsval msg; + if (!JS_GetProperty(cx, JSVAL_TO_OBJECT(exc), "message", &msg)) JS_ClearPendingException(cx); - else if (msg.isString()) - data = msg.toString(); + else if (JSVAL_IS_STRING(msg)) + data = JSVAL_TO_STRING(msg); } if (!data) { data = JS_ValueToString(cx, exc); diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 743a11cabe9..e432a387694 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -1013,12 +1013,11 @@ mozJSComponentLoader::Import(const nsACString& registryLocation, if (optionalArgc) { // The caller passed in the optional second argument. Get it. - if (targetObj.isObjectOrNull()) { - targetObject = targetObj.toObjectOrNull(); - } else { + if (!JSVAL_IS_OBJECT(targetObj)) { return ReportOnCaller(cx, ERROR_SCOPE_OBJ, - PromiseFlatCString(registryLocation).get()); + PromiseFlatCString(registryLocation).get()); } + targetObject = JSVAL_TO_OBJECT(targetObj); } else { // Our targetObject is the caller's global object. Find it by // walking the calling object's parent chain. @@ -1172,6 +1171,7 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation, NS_ASSERTION(mod->global, "Import table contains entry with no global"); *_retval = mod->global; + jsval symbols; if (targetObj) { JSCLContextHelper cxhelper(this); @@ -1179,21 +1179,20 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation, if (!ac.enter(mContext, mod->global)) return NS_ERROR_FAILURE; - JS::Value symbols; if (!JS_GetProperty(mContext, mod->global, "EXPORTED_SYMBOLS", &symbols)) { return ReportOnCaller(cxhelper, ERROR_NOT_PRESENT, PromiseFlatCString(aLocation).get()); } - if (!symbols.isObject() || - !JS_IsArrayObject(mContext, &symbols.toObject())) { + JSObject *symbolsObj = nsnull; + if (!JSVAL_IS_OBJECT(symbols) || + !(symbolsObj = JSVAL_TO_OBJECT(symbols)) || + !JS_IsArrayObject(mContext, symbolsObj)) { return ReportOnCaller(cxhelper, ERROR_NOT_AN_ARRAY, PromiseFlatCString(aLocation).get()); } - JSObject *symbolsObj = &symbols.toObject(); - // Iterate over symbols array, installing symbols on targetObj: uint32_t symbolCount = 0; diff --git a/js/xpconnect/public/nsAutoJSValHolder.h b/js/xpconnect/public/nsAutoJSValHolder.h index 6700a752922..22580ccb628 100644 --- a/js/xpconnect/public/nsAutoJSValHolder.h +++ b/js/xpconnect/public/nsAutoJSValHolder.h @@ -135,8 +135,8 @@ public: * Explicit JSObject* conversion. */ JSObject* ToJSObject() const { - return mVal.isObject() - ? &mVal.toObject() + return JSVAL_IS_OBJECT(mVal) + ? JSVAL_TO_OBJECT(mVal) : nsnull; } diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 9f02da6a1b8..010c8392a8a 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -3315,7 +3315,7 @@ nsXPCComponents_utils_Sandbox::Construct(nsIXPConnectWrappedNative *wrapper, nsresult nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, - PRUint32 argc, JS::Value * argv, + PRUint32 argc, jsval * argv, jsval * vp, bool *_retval) { if (argc < 1) @@ -3327,8 +3327,8 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe nsCOMPtr sop; nsCOMPtr principal; nsISupports *prinOrSop = nsnull; - if (argv[0].isString()) { - JSString *codebaseStr = argv[0].toString(); + if (JSVAL_IS_STRING(argv[0])) { + JSString *codebaseStr = JSVAL_TO_STRING(argv[0]); size_t codebaseLength; const jschar *codebaseChars = JS_GetStringCharsAndLength(cx, codebaseStr, &codebaseLength); @@ -3356,12 +3356,12 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe prinOrSop = principal; } else { - if (argv[0].isObject()) { + if (!JSVAL_IS_PRIMITIVE(argv[0])) { nsCOMPtr xpc(do_GetService(nsIXPConnect::GetCID())); if (!xpc) return NS_ERROR_XPC_UNEXPECTED; nsCOMPtr wrapper; - xpc->GetWrappedNativeOfJSObject(cx, &argv[0].toObject(), + xpc->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(argv[0]), getter_AddRefs(wrapper)); if (wrapper) { @@ -3384,10 +3384,10 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe nsCString sandboxName; if (argc > 1) { - if (!argv[1].isObject()) + if (!JSVAL_IS_OBJECT(argv[1])) return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval); - JSObject *optionsObject = &argv[1].toObject(); + JSObject *optionsObject = JSVAL_TO_OBJECT(argv[1]); jsval option; JSBool found; @@ -3396,11 +3396,11 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe if (found) { if (!JS_GetProperty(cx, optionsObject, "sandboxPrototype", &option) || - !option.isObject()) { + !JSVAL_IS_OBJECT(option)) { return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval); } - proto = &option.toObject(); + proto = JSVAL_TO_OBJECT(option); } if (!JS_HasProperty(cx, optionsObject, "wantXrays", &found)) @@ -3408,11 +3408,11 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe if (found) { if (!JS_GetProperty(cx, optionsObject, "wantXrays", &option) || - !option.isBoolean()) { + !JSVAL_IS_BOOLEAN(option)) { return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval); } - wantXrays = option.toBoolean(); + wantXrays = JSVAL_TO_BOOLEAN(option); } if (!JS_HasProperty(cx, optionsObject, "sandboxName", &found)) @@ -3420,11 +3420,11 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe if (found) { if (!JS_GetProperty(cx, optionsObject, "sandboxName", &option) || - !option.isString()) { + !JSVAL_IS_STRING(option)) { return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval); } - char *tmp = JS_EncodeString(cx, option.toString()); + char *tmp = JS_EncodeString(cx, JSVAL_TO_STRING(option)); if (!tmp) { return ThrowAndFail(NS_ERROR_INVALID_ARG, cx, _retval); } @@ -3869,18 +3869,18 @@ nsXPCComponents_Utils::SchedulePreciseShrinkingGC(ScheduledGCCallback* aCallback /* [implicit_jscontext] jsval nondeterministicGetWeakMapKeys(in jsval aMap); */ NS_IMETHODIMP -nsXPCComponents_Utils::NondeterministicGetWeakMapKeys(const JS::Value &aMap, +nsXPCComponents_Utils::NondeterministicGetWeakMapKeys(const jsval &aMap, JSContext *aCx, - JS::Value *aKeys) + jsval *aKeys) { - if (!aMap.isObject()) { - aKeys->setUndefined(); + if (!JSVAL_IS_OBJECT(aMap)) { + *aKeys = JSVAL_VOID; return NS_OK; } JSObject *objRet; - if (!JS_NondeterministicGetWeakMapKeys(aCx, &aMap.toObject(), &objRet)) + if (!JS_NondeterministicGetWeakMapKeys(aCx, JSVAL_TO_OBJECT(aMap), &objRet)) return NS_ERROR_OUT_OF_MEMORY; - *aKeys = objRet ? ObjectValue(*objRet) : UndefinedValue(); + *aKeys = objRet ? OBJECT_TO_JSVAL(objRet) : JSVAL_VOID; return NS_OK; } @@ -3961,9 +3961,8 @@ nsXPCComponents_Utils::CreateObjectIn(const jsval &vobj, JSContext *cx, jsval *r JSBool FunctionWrapper(JSContext *cx, unsigned argc, jsval *vp) { - JSObject *callee = &JS_CALLEE(cx, vp).toObject(); - JS::Value v = js::GetFunctionNativeReserved(callee, 0); - NS_ASSERTION(v.isObject(), "weird function"); + jsval v = js::GetFunctionNativeReserved(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)), 0); + NS_ASSERTION(JSVAL_IS_OBJECT(v), "weird function"); JSObject *obj = JS_THIS_OBJECT(cx, vp); if (!obj) { diff --git a/js/xpconnect/src/XPCConvert.cpp b/js/xpconnect/src/XPCConvert.cpp index f0219c70f0b..a3731fdc4ff 100644 --- a/js/xpconnect/src/XPCConvert.cpp +++ b/js/xpconnect/src/XPCConvert.cpp @@ -529,17 +529,19 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s, return false; case nsXPTType::T_IID: { - const nsID* pid = nsnull; + JSObject* obj; + const nsID* pid=nsnull; // There's no good reason to pass a null IID. - if (s.isNullOrUndefined()) { + if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) { if (pErr) - *pErr = NS_ERROR_XPC_BAD_CONVERT_JS; + *pErr = NS_ERROR_XPC_BAD_CONVERT_JS; return false; } - if (!s.isObject() || - (!(pid = xpc_JSObjectToID(cx, &s.toObject()))) || + if (!JSVAL_IS_OBJECT(s) || + (!(obj = JSVAL_TO_OBJECT(s))) || + (!(pid = xpc_JSObjectToID(cx, obj))) || (!(pid = (const nsID*) nsMemory::Clone(pid, sizeof(nsID))))) { return false; } @@ -794,6 +796,7 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s, case nsXPTType::T_INTERFACE: case nsXPTType::T_INTERFACE_IS: { + JSObject* obj; NS_ASSERTION(iid,"can't do interface conversions without iid"); if (iid->Equals(NS_GET_IID(nsIVariant))) { @@ -822,19 +825,19 @@ XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s, } //else ... - if (s.isNullOrUndefined()) { + if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) { *((nsISupports**)d) = nsnull; return true; } // only wrap JSObjects - if (!s.isObject()) { - if (pErr && s.isInt32() && 0 == s.toInt32()) + if (!JSVAL_IS_OBJECT(s) || !(obj = JSVAL_TO_OBJECT(s))) { + if (pErr && JSVAL_IS_INT(s) && 0 == JSVAL_TO_INT(s)) *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL; return false; } - return JSObject2NativeInterface(ccx, (void**)d, &s.toObject(), iid, + return JSObject2NativeInterface(ccx, (void**)d, obj, iid, nsnull, pErr); } default: @@ -1740,7 +1743,7 @@ XPCConvert::JSTypedArray2Native(XPCCallContext& ccx, // static JSBool -XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s, +XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, jsval s, uint32_t count, const nsXPTType& type, const nsID* iid, nsresult* pErr) { @@ -1748,11 +1751,21 @@ XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s, JSContext* cx = ccx.GetJSContext(); + // No Action, FRee memory, RElease object + enum CleanupMode {na, fr, re}; + + CleanupMode cleanupMode; + + JSObject* jsarray = nsnull; + void* array = nsnull; + uint32_t initedCount; + jsval current; + // XXX add support for getting chars from strings // XXX add support to indicate *which* array element was not convertable - if (s.isNullOrUndefined()) { + if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) { if (0 != count) { if (pErr) *pErr = NS_ERROR_XPC_NOT_ENOUGH_ELEMENTS_IN_ARRAY; @@ -1763,13 +1776,13 @@ XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s, return true; } - if (!s.isObject()) { + if (!JSVAL_IS_OBJECT(s)) { if (pErr) *pErr = NS_ERROR_XPC_CANT_CONVERT_PRIMITIVE_TO_ARRAY; return false; } - JSObject* jsarray = &s.toObject(); + jsarray = JSVAL_TO_OBJECT(s); // If this is a typed array, then try a fast conversion with memcpy. if (JS_IsTypedArrayObject(jsarray, cx)) { @@ -1810,16 +1823,9 @@ XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, JS::Value s, } \ PR_END_MACRO - // No Action, FRee memory, RElease object - enum CleanupMode {na, fr, re}; - - CleanupMode cleanupMode; - - void *array = nsnull; - uint32_t initedCount; - jsval current; // XXX check IsPtr - esp. to handle array of nsID (as opposed to nsID*) + // XXX make extra space at end of char* and wchar* and null termintate switch (type.TagPart()) { diff --git a/js/xpconnect/src/XPCDebug.cpp b/js/xpconnect/src/XPCDebug.cpp index afd5bc44de7..cfcd4aa6de8 100644 --- a/js/xpconnect/src/XPCDebug.cpp +++ b/js/xpconnect/src/XPCDebug.cpp @@ -79,6 +79,7 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp, PRInt32 lineno = 0; JSFunction* fun = nsnull; uint32_t namedArgCount = 0; + jsval val; JSBool isString; // get the info for this stack frame @@ -151,11 +152,11 @@ static char* FormatJSFrame(JSContext* cx, JSStackFrame* fp, } // print any unnamed trailing args (found in 'arguments' object) - JS::Value val; + if (JS_GetProperty(cx, callObj, "arguments", &val) && - val.isObject()) { + JSVAL_IS_OBJECT(val)) { uint32_t argCount; - JSObject* argsObj = &val.toObject(); + JSObject* argsObj = JSVAL_TO_OBJECT(val); if (JS_GetProperty(cx, argsObj, "length", &val) && JS_ValueToECMAUint32(cx, val, &argCount) && argCount > namedArgCount) { diff --git a/js/xpconnect/src/XPCQuickStubs.cpp b/js/xpconnect/src/XPCQuickStubs.cpp index 3409c76e4a3..5b7f4189b41 100644 --- a/js/xpconnect/src/XPCQuickStubs.cpp +++ b/js/xpconnect/src/XPCQuickStubs.cpp @@ -821,24 +821,24 @@ xpc_qsUnwrapThisFromCcxImpl(XPCCallContext &ccx, } JSObject* -xpc_qsUnwrapObj(JS::Value v, nsISupports **ppArgRef, nsresult *rv) +xpc_qsUnwrapObj(jsval v, nsISupports **ppArgRef, nsresult *rv) { - if (v.isNullOrUndefined()) { + if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v)) { *ppArgRef = nsnull; *rv = NS_OK; return nsnull; } - if (!v.isObject()) { + if (!JSVAL_IS_OBJECT(v)) { *ppArgRef = nsnull; - *rv = ((v.isInt32() && v.toInt32() == 0) + *rv = ((JSVAL_IS_INT(v) && JSVAL_TO_INT(v) == 0) ? NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL : NS_ERROR_XPC_BAD_CONVERT_JS); return nsnull; } *rv = NS_OK; - return &v.toObject(); + return JSVAL_TO_OBJECT(v); } nsresult diff --git a/js/xpconnect/src/XPCVariant.cpp b/js/xpconnect/src/XPCVariant.cpp index d11067dbd65..c962cb38fbd 100644 --- a/js/xpconnect/src/XPCVariant.cpp +++ b/js/xpconnect/src/XPCVariant.cpp @@ -117,8 +117,8 @@ XPCTraceableVariant::PrintTraceName(JSTracer* trc, char *buf, size_t bufsize) #endif NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(XPCVariant) - JS::Value val = tmp->GetJSValPreserveColor(); - if (val.isObjectOrNull()) { + jsval val = tmp->GetJSValPreserveColor(); + if (JSVAL_IS_OBJECT(val)) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mJSVal"); cb.NoteJSChild(JSVAL_TO_OBJECT(val)); } @@ -127,19 +127,19 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(XPCVariant) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(XPCVariant) - JS::Value val = tmp->GetJSValPreserveColor(); + jsval val = tmp->GetJSValPreserveColor(); // We're sharing val's buffer, clear the pointer to it so Cleanup() won't // try to delete it - if (val.isString()) + if (JSVAL_IS_STRING(val)) tmp->mData.u.wstr.mWStringValue = nsnull; nsVariant::Cleanup(&tmp->mData); - if (val.isMarkable()) { + if (JSVAL_IS_TRACEABLE(val)) { XPCTraceableVariant *v = static_cast(tmp); v->RemoveFromRootSet(nsXPConnect::GetRuntimeInstance()->GetMapLock()); } - tmp->mJSVal = JS::NullValue(); + tmp->mJSVal = JSVAL_NULL; NS_IMPL_CYCLE_COLLECTION_UNLINK_END // static @@ -221,26 +221,26 @@ XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array, Type type; for (uint32_t i = 0; i < length; i++) { - JS::Value val; + jsval val; if (!JS_GetElement(ccx, array, i, &val)) return false; - if (val.isInt32()) { + if (JSVAL_IS_INT(val)) type = tInt; - } else if (val.isDouble()) { + else if (JSVAL_IS_DOUBLE(val)) type = tDbl; - } else if (val.isBoolean()) { + else if (JSVAL_IS_BOOLEAN(val)) type = tBool; - } else if (val.isUndefined()) { + else if (JSVAL_IS_VOID(val)) { state = tVar; break; - } else if (val.isNull()) { + } else if (JSVAL_IS_NULL(val)) type = tNull; - } else if (val.isString()) { + else if (JSVAL_IS_STRING(val)) type = tStr; - } else { - NS_ASSERTION(val.isObject(), "invalid type of jsval!"); - JSObject* jsobj = &val.toObject(); + else { + NS_ASSERTION(JSVAL_IS_OBJECT(val), "invalid type of jsval!"); + JSObject* jsobj = JSVAL_TO_OBJECT(val); if (JS_IsArrayObject(ccx, jsobj)) type = tArr; else if (xpc_JSObjectIsID(ccx, jsobj)) @@ -306,22 +306,24 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx) { JS_CHECK_RECURSION(ccx.GetJSContext(), return false); - JS::Value val = GetJSVal(); + jsval val = GetJSVal(); - if (val.isInt32()) - return NS_SUCCEEDED(nsVariant::SetFromInt32(&mData, val.toInt32())); - if (val.isDouble()) - return NS_SUCCEEDED(nsVariant::SetFromDouble(&mData, val.toDouble())); - if (val.isBoolean()) - return NS_SUCCEEDED(nsVariant::SetFromBool(&mData, val.toBoolean())); - if (val.isUndefined()) + if (JSVAL_IS_INT(val)) + return NS_SUCCEEDED(nsVariant::SetFromInt32(&mData, JSVAL_TO_INT(val))); + if (JSVAL_IS_DOUBLE(val)) + return NS_SUCCEEDED(nsVariant::SetFromDouble(&mData, + JSVAL_TO_DOUBLE(val))); + if (JSVAL_IS_BOOLEAN(val)) + return NS_SUCCEEDED(nsVariant::SetFromBool(&mData, + JSVAL_TO_BOOLEAN(val))); + if (JSVAL_IS_VOID(val)) return NS_SUCCEEDED(nsVariant::SetToVoid(&mData)); - if (val.isNull()) + if (JSVAL_IS_NULL(val)) return NS_SUCCEEDED(nsVariant::SetToEmpty(&mData)); - if (val.isString()) { + if (JSVAL_IS_STRING(val)) { // Make our string immutable. This will also ensure null-termination, // which nsVariant assumes for its PRUnichar* stuff. - JSString* str = val.toString(); + JSString* str = JSVAL_TO_STRING(val); if (!JS_MakeStringImmutable(ccx, str)) return false; @@ -348,9 +350,9 @@ JSBool XPCVariant::InitializeData(XPCCallContext& ccx) } // leaving only JSObject... - NS_ASSERTION(val.isObject(), "invalid type of jsval!"); + NS_ASSERTION(JSVAL_IS_OBJECT(val), "invalid type of jsval!"); - JSObject* jsobj = &val.toObject(); + JSObject* jsobj = JSVAL_TO_OBJECT(val); // Let's see if it is a xpcJSID. diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp index d0038aa6de3..18019fee528 100644 --- a/js/xpconnect/src/XPCWrappedJSClass.cpp +++ b/js/xpconnect/src/XPCWrappedJSClass.cpp @@ -308,14 +308,14 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(XPCCallContext& ccx, if (JS_GetPendingException(cx, &jsexception)) { nsresult rv; - if (jsexception.isObject()) { + if (JSVAL_IS_OBJECT(jsexception)) { // XPConnect may have constructed an object to represent a // C++ QI failure. See if that is the case. nsCOMPtr wrapper; nsXPConnect::GetXPConnect()-> GetWrappedNativeOfJSObject(ccx, - &jsexception.toObject(), + JSVAL_TO_OBJECT(jsexception), getter_AddRefs(wrapper)); if (wrapper) { diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index e0aafdc9a3c..c88251943f6 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -2644,9 +2644,9 @@ CallMethodHelper::GatherAndConvertResults() mCallContext.SetRetVal(v); } else if (i < mArgc) { // we actually assured this before doing the invoke - NS_ASSERTION(mArgv[i].isObject(), "out var is not object"); + NS_ASSERTION(JSVAL_IS_OBJECT(mArgv[i]), "out var is not object"); if (!JS_SetPropertyById(mCallContext, - &mArgv[i].toObject(), + JSVAL_TO_OBJECT(mArgv[i]), mIdxValueId, &v)) { ThrowBadParam(NS_ERROR_XPC_CANT_SET_OUT_VAL, i, mCallContext); return false; @@ -2670,14 +2670,11 @@ CallMethodHelper::QueryInterfaceFastPath() const Throw(NS_ERROR_XPC_NOT_ENOUGH_ARGS, mCallContext); return false; } - - if (!mArgv[0].isObject()) { - ThrowBadParam(NS_ERROR_XPC_BAD_CONVERT_JS, 0, mCallContext); - return false; - } - - const nsID* iid = xpc_JSObjectToID(mCallContext, &mArgv[0].toObject()); - if (!iid) { + const nsID* iid; + JSObject* obj; + if (!JSVAL_IS_OBJECT(mArgv[0]) || + (!(obj = JSVAL_TO_OBJECT(mArgv[0]))) || + (!(iid = xpc_JSObjectToID(mCallContext, obj)))) { ThrowBadParam(NS_ERROR_XPC_BAD_CONVERT_JS, 0, mCallContext); return false; } diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index a34744ebcef..7a7307c9690 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -2890,29 +2890,30 @@ JS_EXPORT_API(void) DumpJSObject(JSObject* obj) xpc_DumpJSObject(obj); } -JS_EXPORT_API(void) DumpJSValue(JS::Value val) +JS_EXPORT_API(void) DumpJSValue(jsval val) { - printf("Dumping 0x%llu.\n", (long long) val.asRawBits()); - if (val.isNull()) { + printf("Dumping 0x%llu.\n", (long long) JSVAL_TO_IMPL(val).asBits); + if (JSVAL_IS_NULL(val)) { printf("Value is null\n"); - } else if (val.isObject()) { + } else if (JSVAL_IS_OBJECT(val) || JSVAL_IS_NULL(val)) { printf("Value is an object\n"); - DumpJSObject(&val.toObject()); - } else if (val.isNumber()) { + JSObject* obj = JSVAL_TO_OBJECT(val); + DumpJSObject(obj); + } else if (JSVAL_IS_NUMBER(val)) { printf("Value is a number: "); - if (val.isInt32()) - printf("Integer %i\n", val.toInt32()); - else if (val.isDouble()) - printf("Floating-point value %f\n", val.toDouble()); - } else if (val.isString()) { + if (JSVAL_IS_INT(val)) + printf("Integer %i\n", JSVAL_TO_INT(val)); + else if (JSVAL_IS_DOUBLE(val)) + printf("Floating-point value %f\n", JSVAL_TO_DOUBLE(val)); + } else if (JSVAL_IS_STRING(val)) { printf("Value is a string: "); putc('<', stdout); - JS_FileEscapedString(stdout, val.toString(), 0); + JS_FileEscapedString(stdout, JSVAL_TO_STRING(val), 0); fputs(">\n", stdout); - } else if (val.isBoolean()) { + } else if (JSVAL_IS_BOOLEAN(val)) { printf("Value is boolean: "); - printf(val.isTrue() ? "true" : "false"); - } else if (val.isUndefined()) { + printf(JSVAL_TO_BOOLEAN(val) ? "true" : "false"); + } else if (JSVAL_IS_VOID(val)) { printf("Value is undefined\n"); } else { printf("No idea what this value is.\n"); diff --git a/js/xpconnect/wrappers/AccessCheck.cpp b/js/xpconnect/wrappers/AccessCheck.cpp index 5cd374c7047..85a30506988 100644 --- a/js/xpconnect/wrappers/AccessCheck.cpp +++ b/js/xpconnect/wrappers/AccessCheck.cpp @@ -533,20 +533,20 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapper, jsid id, Wrapper: return true; } - JS::Value exposedProps; + jsval exposedProps; if (!JS_LookupPropertyById(cx, wrappedObject, exposedPropsId, &exposedProps)) return false; - if (exposedProps.isNullOrUndefined()) { + if (JSVAL_IS_VOID(exposedProps) || JSVAL_IS_NULL(exposedProps)) { return PermitIfUniversalXPConnect(cx, id, act, perm); // Deny } - if (!exposedProps.isObject()) { + if (!JSVAL_IS_OBJECT(exposedProps)) { JS_ReportError(cx, "__exposedProps__ must be undefined, null, or an Object"); return false; } - JSObject *hallpass = &exposedProps.toObject(); + JSObject *hallpass = JSVAL_TO_OBJECT(exposedProps); Access access = NO_ACCESS; diff --git a/storage/src/mozStoragePrivateHelpers.cpp b/storage/src/mozStoragePrivateHelpers.cpp index 24fdf27b69e..5fed1d102b1 100644 --- a/storage/src/mozStoragePrivateHelpers.cpp +++ b/storage/src/mozStoragePrivateHelpers.cpp @@ -147,29 +147,30 @@ checkAndLogStatementPerformance(sqlite3_stmt *aStatement) nsIVariant * convertJSValToVariant( JSContext *aCtx, - JS::Value aValue) + jsval aValue) { - if (aValue.isInt32()) - return new IntegerVariant(aValue.toInt32()); + if (JSVAL_IS_INT(aValue)) + return new IntegerVariant(JSVAL_TO_INT(aValue)); - if (aValue.isDouble()) - return new FloatVariant(aValue.toDouble()); + if (JSVAL_IS_DOUBLE(aValue)) + return new FloatVariant(JSVAL_TO_DOUBLE(aValue)); - if (aValue.isString()) { + if (JSVAL_IS_STRING(aValue)) { + JSString *str = JSVAL_TO_STRING(aValue); nsDependentJSString value; - if (!value.init(aCtx, aValue)) + if (!value.init(aCtx, str)) return nsnull; return new TextVariant(value); } - if (aValue.isBoolean()) - return new IntegerVariant(aValue.isTrue() ? 1 : 0); + if (JSVAL_IS_BOOLEAN(aValue)) + return new IntegerVariant((aValue == JSVAL_TRUE) ? 1 : 0); - if (aValue.isNull()) + if (JSVAL_IS_NULL(aValue)) return new NullVariant(); - if (aValue.isObject()) { - JSObject* obj = &aValue.toObject(); + if (JSVAL_IS_OBJECT(aValue)) { + JSObject *obj = JSVAL_TO_OBJECT(aValue); // We only support Date instances, all others fail. if (!::js_DateIsValid(aCtx, obj)) return nsnull;