diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp index 66babd66aff2..21af38d9f67d 100644 --- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -1271,7 +1271,7 @@ EventSource::DispatchAllMessageEvents() message->mData.Length()); NS_ENSURE_TRUE_VOID(jsString); - jsData = STRING_TO_JSVAL(jsString); + jsData.setString(jsString); } // create an event that uses the MessageEvent interface, diff --git a/dom/base/WebSocket.cpp b/dom/base/WebSocket.cpp index dc5d7b1a59c7..1522c6549be6 100644 --- a/dom/base/WebSocket.cpp +++ b/dom/base/WebSocket.cpp @@ -1776,7 +1776,7 @@ WebSocket::CreateAndDispatchMessageEvent(JSContext* aCx, jsString = JS_NewUCStringCopyN(aCx, utf16Data.get(), utf16Data.Length()); NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE); - jsData = STRING_TO_JSVAL(jsString); + jsData.setString(jsString); } // create an event that uses the MessageEvent interface, diff --git a/dom/base/nsDOMDataChannel.cpp b/dom/base/nsDOMDataChannel.cpp index 919dfbd08419..9a6765c715a4 100644 --- a/dom/base/nsDOMDataChannel.cpp +++ b/dom/base/nsDOMDataChannel.cpp @@ -399,7 +399,7 @@ nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData, JSString* jsString = JS_NewUCStringCopyN(cx, utf16data.get(), utf16data.Length()); NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE); - jsData = STRING_TO_JSVAL(jsString); + jsData.setString(jsString); } nsCOMPtr event; diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 861bf9b9fd3d..459d3354cc13 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -931,7 +931,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv) JSString *str = ::JS_NewStringCopyN(cx, data.get(), data.Length()); NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY); - *aArgv = STRING_TO_JSVAL(str); + aArgv->setString(str); break; } @@ -949,7 +949,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv) ::JS_NewUCStringCopyN(cx, data.get(), data.Length()); NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY); - *aArgv = STRING_TO_JSVAL(str); + aArgv->setString(str); break; } case nsISupportsPrimitive::TYPE_PRBOOL : { @@ -960,7 +960,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv) p->GetData(&data); - *aArgv = BOOLEAN_TO_JSVAL(data); + aArgv->setBoolean(data); break; } @@ -1011,7 +1011,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv) JSString *str = ::JS_NewStringCopyN(cx, &data, 1); NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY); - *aArgv = STRING_TO_JSVAL(str); + aArgv->setString(str); break; } diff --git a/dom/bluetooth/BluetoothUtils.cpp b/dom/bluetooth/BluetoothUtils.cpp index ddbe635f1c30..92bfc31fbf5c 100644 --- a/dom/bluetooth/BluetoothUtils.cpp +++ b/dom/bluetooth/BluetoothUtils.cpp @@ -155,14 +155,14 @@ SetJsObject(JSContext* aContext, v.get_nsString().BeginReading(), v.get_nsString().Length()); NS_ENSURE_TRUE(jsData, false); - val = STRING_TO_JSVAL(jsData); + val.setString(jsData); break; } case BluetoothValue::Tuint32_t: val = INT_TO_JSVAL(v.get_uint32_t()); break; case BluetoothValue::Tbool: - val = BOOLEAN_TO_JSVAL(v.get_bool()); + val.setBoolean(v.get_bool()); break; default: BT_WARNING("SetJsObject: Parameter is not handled"); @@ -197,7 +197,7 @@ BroadcastSystemMessage(const nsAString& aType, JSString* jsData = JS_NewUCStringCopyN(cx, aData.get_nsString().BeginReading(), aData.get_nsString().Length()); - value = STRING_TO_JSVAL(jsData); + value.setString(jsData); } else if (aData.type() == BluetoothValue::TArrayOfBluetoothNamedValue) { JS::Rooted obj(cx, JS_NewPlainObject(cx)); if (!obj) { diff --git a/dom/mobilemessage/MobileMessageCallback.cpp b/dom/mobilemessage/MobileMessageCallback.cpp index 47bd301bfaa7..1e8e82ee7628 100644 --- a/dom/mobilemessage/MobileMessageCallback.cpp +++ b/dom/mobilemessage/MobileMessageCallback.cpp @@ -290,7 +290,7 @@ MobileMessageCallback::NotifyGetSmscAddress(const nsAString& aSmscAddress) return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR); } - JS::Rooted val(cx, STRING_TO_JSVAL(smsc)); + JS::Rooted val(cx, JS::StringValue(smsc)); return NotifySuccess(val); } diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index 11c66bcc6f05..c0dd8ca3c002 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -489,7 +489,7 @@ NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant) case NPVariantType_Null : return JS::NullValue(); case NPVariantType_Bool : - return BOOLEAN_TO_JSVAL(NPVARIANT_TO_BOOLEAN(*variant)); + return JS::BooleanValue(NPVARIANT_TO_BOOLEAN(*variant)); case NPVariantType_Int32 : { // Don't use INT_TO_JSVAL directly to prevent bugs when dealing @@ -509,7 +509,7 @@ NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant) ::JS_NewUCStringCopyN(cx, utf16String.get(), utf16String.Length()); if (str) { - return STRING_TO_JSVAL(str); + return JS::StringValue(str); } break; diff --git a/dom/system/OSFileConstants.cpp b/dom/system/OSFileConstants.cpp index e3c63c52066e..8594cfb61ba7 100644 --- a/dom/system/OSFileConstants.cpp +++ b/dom/system/OSFileConstants.cpp @@ -824,7 +824,7 @@ bool SetStringProperty(JSContext *cx, JS::Handle aObject, const char } JSString* strValue = JS_NewUCStringCopyZ(cx, aValue.get()); NS_ENSURE_TRUE(strValue, false); - JS::Rooted valValue(cx, STRING_TO_JSVAL(strValue)); + JS::Rooted valValue(cx, JS::StringValue(strValue)); return JS_SetProperty(cx, aObject, aProperty, valValue); } @@ -891,7 +891,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle global) if (!strVersion){ return false; } - JS::Rooted valVersion(cx, STRING_TO_JSVAL(strVersion)); + JS::Rooted valVersion(cx, JS::StringValue(strVersion)); if (!JS_SetProperty(cx, objSys, "Name", valVersion)) { return false; } @@ -907,7 +907,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle global) return false; } - JS::Rooted valVersion(cx, STRING_TO_JSVAL(strVersion)); + JS::Rooted valVersion(cx, JS::StringValue(strVersion)); if (!JS_SetProperty(cx, objSys, "Name", valVersion)) { return false; } diff --git a/dom/workers/XMLHttpRequest.cpp b/dom/workers/XMLHttpRequest.cpp index f422b6a2dd7e..1975893989b7 100644 --- a/dom/workers/XMLHttpRequest.cpp +++ b/dom/workers/XMLHttpRequest.cpp @@ -2457,7 +2457,7 @@ XMLHttpRequest::GetResponse(JSContext* /* unused */, return; } - mStateData.mResponse = STRING_TO_JSVAL(str); + mStateData.mResponse.setString(str); } } diff --git a/js/ipc/JavaScriptShared.cpp b/js/ipc/JavaScriptShared.cpp index 300e375db0e6..70d6d7207c56 100644 --- a/js/ipc/JavaScriptShared.cpp +++ b/js/ipc/JavaScriptShared.cpp @@ -362,7 +362,7 @@ JavaScriptShared::fromVariant(JSContext* cx, const JSVariant& from, MutableHandl return true; case JSVariant::Tbool: - to.set(BOOLEAN_TO_JSVAL(from.get_bool())); + to.setBoolean(from.get_bool()); return true; case JSVariant::TnsString: diff --git a/js/public/Value.h b/js/public/Value.h index 6934f1d10e61..a790c4aacf0c 100644 --- a/js/public/Value.h +++ b/js/public/Value.h @@ -1971,12 +1971,6 @@ UINT_TO_JSVAL(uint32_t i) : DOUBLE_TO_JSVAL((double)i); } -static inline jsval -STRING_TO_JSVAL(JSString* str) -{ - return IMPL_TO_JSVAL(STRING_TO_JSVAL_IMPL(str)); -} - static inline jsval OBJECT_TO_JSVAL(JSObject* obj) { @@ -1985,12 +1979,6 @@ OBJECT_TO_JSVAL(JSObject* obj) return IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_NULL, 0)); } -static inline jsval -BOOLEAN_TO_JSVAL(bool b) -{ - return IMPL_TO_JSVAL(BOOLEAN_TO_JSVAL_IMPL(b)); -} - /* To be GC-safe, privates are tagged as doubles. */ static inline jsval diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index 9dd4445b4c77..912f4749756e 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -3931,7 +3931,7 @@ CType::Create(JSContext* cx, if (ffiType) JS_SetReservedSlot(typeObj, SLOT_FFITYPE, PRIVATE_TO_JSVAL(ffiType)); if (name) - JS_SetReservedSlot(typeObj, SLOT_NAME, STRING_TO_JSVAL(name)); + JS_SetReservedSlot(typeObj, SLOT_NAME, StringValue(name)); JS_SetReservedSlot(typeObj, SLOT_SIZE, size); JS_SetReservedSlot(typeObj, SLOT_ALIGN, align); @@ -4291,7 +4291,7 @@ CType::GetName(JSContext* cx, HandleObject obj) JSString* name = BuildTypeName(cx, obj); if (!name) return nullptr; - JS_SetReservedSlot(obj, SLOT_NAME, STRING_TO_JSVAL(name)); + JS_SetReservedSlot(obj, SLOT_NAME, StringValue(name)); return name; } @@ -7086,7 +7086,7 @@ CData::Create(JSContext* cx, JS_SetReservedSlot(dataObj, SLOT_REFERENT, OBJECT_TO_JSVAL(refObj)); // Set our ownership flag. - JS_SetReservedSlot(dataObj, SLOT_OWNS, BOOLEAN_TO_JSVAL(ownResult)); + JS_SetReservedSlot(dataObj, SLOT_OWNS, BooleanValue(ownResult)); // attach the buffer. since it might not be 2-byte aligned, we need to // allocate an aligned space for it and store it there. :( diff --git a/js/src/gdb/tests/test-Root.cpp b/js/src/gdb/tests/test-Root.cpp index d877418587db..e067a0bea0a8 100644 --- a/js/src/gdb/tests/test-Root.cpp +++ b/js/src/gdb/tests/test-Root.cpp @@ -28,7 +28,7 @@ FRAGMENT(Root, handle) { } FRAGMENT(Root, HeapSlot) { - JS::Rooted plinth(cx, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, "plinth"))); + JS::Rooted plinth(cx, JS::StringValue(JS_NewStringCopyZ(cx, "plinth"))); JS::Rooted array(cx, JS_NewArrayObject(cx, JS::HandleValueArray(plinth))); breakpoint(); diff --git a/js/src/jsapi-tests/testParseJSON.cpp b/js/src/jsapi-tests/testParseJSON.cpp index 7fc56d183de4..142b2090a7e2 100644 --- a/js/src/jsapi-tests/testParseJSON.cpp +++ b/js/src/jsapi-tests/testParseJSON.cpp @@ -74,26 +74,26 @@ BEGIN_TEST(testParseJSON_success) const char16_t emptystr[] = { '\0' }; str = js::NewStringCopyN(cx, emptystr, 0); CHECK(str); - expected = STRING_TO_JSVAL(str); + expected = JS::StringValue(str); CHECK(TryParse(cx, "\"\"", expected)); const char16_t nullstr[] = { '\0' }; str = NewString(cx, nullstr); CHECK(str); - expected = STRING_TO_JSVAL(str); + expected = JS::StringValue(str); CHECK(TryParse(cx, "\"\\u0000\"", expected)); const char16_t backstr[] = { '\b' }; str = NewString(cx, backstr); CHECK(str); - expected = STRING_TO_JSVAL(str); + expected = JS::StringValue(str); CHECK(TryParse(cx, "\"\\b\"", expected)); CHECK(TryParse(cx, "\"\\u0008\"", expected)); const char16_t newlinestr[] = { '\n', }; str = NewString(cx, newlinestr); CHECK(str); - expected = STRING_TO_JSVAL(str); + expected = JS::StringValue(str); CHECK(TryParse(cx, "\"\\n\"", expected)); CHECK(TryParse(cx, "\"\\u000A\"", expected)); diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index bc5a561332c6..2ec9a4cbcded 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -287,7 +287,7 @@ JS_GetPositiveInfinityValue(JSContext* cx) JS_PUBLIC_API(jsval) JS_GetEmptyStringValue(JSContext* cx) { - return STRING_TO_JSVAL(cx->runtime()->emptyString); + return StringValue(cx->runtime()->emptyString); } JS_PUBLIC_API(JSString*) diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 178e787e0d1f..60c573e8a716 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -3532,7 +3532,7 @@ XPCJSRuntime::OnJSContextNew(JSContext* cx) return false; } mStrIDs[i] = INTERNED_STRING_TO_JSID(cx, str); - mStrJSVals[i] = STRING_TO_JSVAL(str); + mStrJSVals[i].setString(str); } if (!mozilla::dom::DefineStaticJSVals(cx)) { diff --git a/js/xpconnect/src/XPCLocale.cpp b/js/xpconnect/src/XPCLocale.cpp index 2179554e43e5..37b504f20b13 100644 --- a/js/xpconnect/src/XPCLocale.cpp +++ b/js/xpconnect/src/XPCLocale.cpp @@ -115,7 +115,7 @@ private: return false; } - rval.set(STRING_TO_JSVAL(ucstr)); + rval.setString(ucstr); return true; } diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index 710400be1d4c..87bad4e6475b 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -712,7 +712,7 @@ env_setProperty(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue JS_ReportError(cx, "can't set envariable %s to %s", name.ptr(), value.ptr()); return false; } - vp.set(STRING_TO_JSVAL(valstr)); + vp.setString(valstr); #endif /* !defined SOLARIS */ return result.succeed(); } diff --git a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp index 71a5c94f5b68..8808a55e0d6f 100644 --- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp +++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp @@ -61,7 +61,7 @@ ToStringGuts(XPCCallContext& ccx) if (!str) return false; - ccx.SetRetVal(STRING_TO_JSVAL(str)); + ccx.SetRetVal(JS::StringValue(str)); return true; } diff --git a/storage/mozStorageStatementJSHelper.cpp b/storage/mozStorageStatementJSHelper.cpp index 9db095e55b19..59db1f4454fb 100644 --- a/storage/mozStorageStatementJSHelper.cpp +++ b/storage/mozStorageStatementJSHelper.cpp @@ -71,7 +71,7 @@ stepFunc(JSContext *aCtx, return false; } - *_vp = BOOLEAN_TO_JSVAL(hasMore); + _vp->setBoolean(hasMore); return true; } diff --git a/storage/mozStorageStatementRow.cpp b/storage/mozStorageStatementRow.cpp index ee5409831c1a..f582a31a573f 100644 --- a/storage/mozStorageStatementRow.cpp +++ b/storage/mozStorageStatementRow.cpp @@ -80,7 +80,7 @@ StatementRow::GetProperty(nsIXPConnectWrappedNative *aWrapper, *_retval = false; return NS_OK; } - *_vp = STRING_TO_JSVAL(str); + _vp->setString(str); } else if (type == mozIStorageValueArray::VALUE_TYPE_BLOB) { uint32_t length;