Bug 1177892 part 1 - Remove BOOLEAN_TO_JSVAL and STRING_TO_JSVAL. r=evilpie

This commit is contained in:
Jan de Mooij 2015-06-30 11:20:56 -07:00
parent e5fac62ec1
commit c3dfaeab46
21 changed files with 33 additions and 45 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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<nsIDOMEvent> event;

View File

@ -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;
}

View File

@ -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<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {

View File

@ -290,7 +290,7 @@ MobileMessageCallback::NotifyGetSmscAddress(const nsAString& aSmscAddress)
return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
}
JS::Rooted<JS::Value> val(cx, STRING_TO_JSVAL(smsc));
JS::Rooted<JS::Value> val(cx, JS::StringValue(smsc));
return NotifySuccess(val);
}

View File

@ -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;

View File

@ -824,7 +824,7 @@ bool SetStringProperty(JSContext *cx, JS::Handle<JSObject*> aObject, const char
}
JSString* strValue = JS_NewUCStringCopyZ(cx, aValue.get());
NS_ENSURE_TRUE(strValue, false);
JS::Rooted<JS::Value> valValue(cx, STRING_TO_JSVAL(strValue));
JS::Rooted<JS::Value> valValue(cx, JS::StringValue(strValue));
return JS_SetProperty(cx, aObject, aProperty, valValue);
}
@ -891,7 +891,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
if (!strVersion){
return false;
}
JS::Rooted<JS::Value> valVersion(cx, STRING_TO_JSVAL(strVersion));
JS::Rooted<JS::Value> valVersion(cx, JS::StringValue(strVersion));
if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
return false;
}
@ -907,7 +907,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
return false;
}
JS::Rooted<JS::Value> valVersion(cx, STRING_TO_JSVAL(strVersion));
JS::Rooted<JS::Value> valVersion(cx, JS::StringValue(strVersion));
if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
return false;
}

View File

@ -2457,7 +2457,7 @@ XMLHttpRequest::GetResponse(JSContext* /* unused */,
return;
}
mStateData.mResponse = STRING_TO_JSVAL(str);
mStateData.mResponse.setString(str);
}
}

View File

@ -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:

View File

@ -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

View File

@ -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. :(

View File

@ -28,7 +28,7 @@ FRAGMENT(Root, handle) {
}
FRAGMENT(Root, HeapSlot) {
JS::Rooted<jsval> plinth(cx, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, "plinth")));
JS::Rooted<jsval> plinth(cx, JS::StringValue(JS_NewStringCopyZ(cx, "plinth")));
JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, JS::HandleValueArray(plinth)));
breakpoint();

View File

@ -74,26 +74,26 @@ BEGIN_TEST(testParseJSON_success)
const char16_t emptystr[] = { '\0' };
str = js::NewStringCopyN<CanGC>(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));

View File

@ -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*)

View File

@ -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)) {

View File

@ -115,7 +115,7 @@ private:
return false;
}
rval.set(STRING_TO_JSVAL(ucstr));
rval.setString(ucstr);
return true;
}

View File

@ -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();
}

View File

@ -61,7 +61,7 @@ ToStringGuts(XPCCallContext& ccx)
if (!str)
return false;
ccx.SetRetVal(STRING_TO_JSVAL(str));
ccx.SetRetVal(JS::StringValue(str));
return true;
}

View File

@ -71,7 +71,7 @@ stepFunc(JSContext *aCtx,
return false;
}
*_vp = BOOLEAN_TO_JSVAL(hasMore);
_vp->setBoolean(hasMore);
return true;
}

View File

@ -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;