зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1177892 part 1 - Remove BOOLEAN_TO_JSVAL and STRING_TO_JSVAL. r=evilpie
This commit is contained in:
Родитель
cfb4123d75
Коммит
155b1afd35
|
@ -1271,7 +1271,7 @@ EventSource::DispatchAllMessageEvents()
|
||||||
message->mData.Length());
|
message->mData.Length());
|
||||||
NS_ENSURE_TRUE_VOID(jsString);
|
NS_ENSURE_TRUE_VOID(jsString);
|
||||||
|
|
||||||
jsData = STRING_TO_JSVAL(jsString);
|
jsData.setString(jsString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create an event that uses the MessageEvent interface,
|
// create an event that uses the MessageEvent interface,
|
||||||
|
|
|
@ -1776,7 +1776,7 @@ WebSocket::CreateAndDispatchMessageEvent(JSContext* aCx,
|
||||||
jsString = JS_NewUCStringCopyN(aCx, utf16Data.get(), utf16Data.Length());
|
jsString = JS_NewUCStringCopyN(aCx, utf16Data.get(), utf16Data.Length());
|
||||||
NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
jsData = STRING_TO_JSVAL(jsString);
|
jsData.setString(jsString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create an event that uses the MessageEvent interface,
|
// create an event that uses the MessageEvent interface,
|
||||||
|
|
|
@ -399,7 +399,7 @@ nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData,
|
||||||
JSString* jsString = JS_NewUCStringCopyN(cx, utf16data.get(), utf16data.Length());
|
JSString* jsString = JS_NewUCStringCopyN(cx, utf16data.get(), utf16data.Length());
|
||||||
NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
jsData = STRING_TO_JSVAL(jsString);
|
jsData.setString(jsString);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMEvent> event;
|
nsCOMPtr<nsIDOMEvent> event;
|
||||||
|
|
|
@ -931,7 +931,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
|
||||||
JSString *str = ::JS_NewStringCopyN(cx, data.get(), data.Length());
|
JSString *str = ::JS_NewStringCopyN(cx, data.get(), data.Length());
|
||||||
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
*aArgv = STRING_TO_JSVAL(str);
|
aArgv->setString(str);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -949,7 +949,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
|
||||||
::JS_NewUCStringCopyN(cx, data.get(), data.Length());
|
::JS_NewUCStringCopyN(cx, data.get(), data.Length());
|
||||||
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
*aArgv = STRING_TO_JSVAL(str);
|
aArgv->setString(str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case nsISupportsPrimitive::TYPE_PRBOOL : {
|
case nsISupportsPrimitive::TYPE_PRBOOL : {
|
||||||
|
@ -960,7 +960,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
|
||||||
|
|
||||||
p->GetData(&data);
|
p->GetData(&data);
|
||||||
|
|
||||||
*aArgv = BOOLEAN_TO_JSVAL(data);
|
aArgv->setBoolean(data);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1011,7 +1011,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
|
||||||
JSString *str = ::JS_NewStringCopyN(cx, &data, 1);
|
JSString *str = ::JS_NewStringCopyN(cx, &data, 1);
|
||||||
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
*aArgv = STRING_TO_JSVAL(str);
|
aArgv->setString(str);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,14 +155,14 @@ SetJsObject(JSContext* aContext,
|
||||||
v.get_nsString().BeginReading(),
|
v.get_nsString().BeginReading(),
|
||||||
v.get_nsString().Length());
|
v.get_nsString().Length());
|
||||||
NS_ENSURE_TRUE(jsData, false);
|
NS_ENSURE_TRUE(jsData, false);
|
||||||
val = STRING_TO_JSVAL(jsData);
|
val.setString(jsData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BluetoothValue::Tuint32_t:
|
case BluetoothValue::Tuint32_t:
|
||||||
val = INT_TO_JSVAL(v.get_uint32_t());
|
val = INT_TO_JSVAL(v.get_uint32_t());
|
||||||
break;
|
break;
|
||||||
case BluetoothValue::Tbool:
|
case BluetoothValue::Tbool:
|
||||||
val = BOOLEAN_TO_JSVAL(v.get_bool());
|
val.setBoolean(v.get_bool());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BT_WARNING("SetJsObject: Parameter is not handled");
|
BT_WARNING("SetJsObject: Parameter is not handled");
|
||||||
|
@ -197,7 +197,7 @@ BroadcastSystemMessage(const nsAString& aType,
|
||||||
JSString* jsData = JS_NewUCStringCopyN(cx,
|
JSString* jsData = JS_NewUCStringCopyN(cx,
|
||||||
aData.get_nsString().BeginReading(),
|
aData.get_nsString().BeginReading(),
|
||||||
aData.get_nsString().Length());
|
aData.get_nsString().Length());
|
||||||
value = STRING_TO_JSVAL(jsData);
|
value.setString(jsData);
|
||||||
} else if (aData.type() == BluetoothValue::TArrayOfBluetoothNamedValue) {
|
} else if (aData.type() == BluetoothValue::TArrayOfBluetoothNamedValue) {
|
||||||
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
|
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
|
|
|
@ -290,7 +290,7 @@ MobileMessageCallback::NotifyGetSmscAddress(const nsAString& aSmscAddress)
|
||||||
return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
|
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);
|
return NotifySuccess(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -489,7 +489,7 @@ NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant)
|
||||||
case NPVariantType_Null :
|
case NPVariantType_Null :
|
||||||
return JS::NullValue();
|
return JS::NullValue();
|
||||||
case NPVariantType_Bool :
|
case NPVariantType_Bool :
|
||||||
return BOOLEAN_TO_JSVAL(NPVARIANT_TO_BOOLEAN(*variant));
|
return JS::BooleanValue(NPVARIANT_TO_BOOLEAN(*variant));
|
||||||
case NPVariantType_Int32 :
|
case NPVariantType_Int32 :
|
||||||
{
|
{
|
||||||
// Don't use INT_TO_JSVAL directly to prevent bugs when dealing
|
// 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());
|
::JS_NewUCStringCopyN(cx, utf16String.get(), utf16String.Length());
|
||||||
|
|
||||||
if (str) {
|
if (str) {
|
||||||
return STRING_TO_JSVAL(str);
|
return JS::StringValue(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -824,7 +824,7 @@ bool SetStringProperty(JSContext *cx, JS::Handle<JSObject*> aObject, const char
|
||||||
}
|
}
|
||||||
JSString* strValue = JS_NewUCStringCopyZ(cx, aValue.get());
|
JSString* strValue = JS_NewUCStringCopyZ(cx, aValue.get());
|
||||||
NS_ENSURE_TRUE(strValue, false);
|
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);
|
return JS_SetProperty(cx, aObject, aProperty, valValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -891,7 +891,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
|
||||||
if (!strVersion){
|
if (!strVersion){
|
||||||
return false;
|
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)) {
|
if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -907,7 +907,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
|
||||||
return false;
|
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)) {
|
if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2457,7 +2457,7 @@ XMLHttpRequest::GetResponse(JSContext* /* unused */,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mStateData.mResponse = STRING_TO_JSVAL(str);
|
mStateData.mResponse.setString(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,7 @@ JavaScriptShared::fromVariant(JSContext* cx, const JSVariant& from, MutableHandl
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case JSVariant::Tbool:
|
case JSVariant::Tbool:
|
||||||
to.set(BOOLEAN_TO_JSVAL(from.get_bool()));
|
to.setBoolean(from.get_bool());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case JSVariant::TnsString:
|
case JSVariant::TnsString:
|
||||||
|
|
|
@ -1971,12 +1971,6 @@ UINT_TO_JSVAL(uint32_t i)
|
||||||
: DOUBLE_TO_JSVAL((double)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
|
static inline jsval
|
||||||
OBJECT_TO_JSVAL(JSObject* obj)
|
OBJECT_TO_JSVAL(JSObject* obj)
|
||||||
{
|
{
|
||||||
|
@ -1985,12 +1979,6 @@ OBJECT_TO_JSVAL(JSObject* obj)
|
||||||
return IMPL_TO_JSVAL(BUILD_JSVAL(JSVAL_TAG_NULL, 0));
|
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. */
|
/* To be GC-safe, privates are tagged as doubles. */
|
||||||
|
|
||||||
static inline jsval
|
static inline jsval
|
||||||
|
|
|
@ -3931,7 +3931,7 @@ CType::Create(JSContext* cx,
|
||||||
if (ffiType)
|
if (ffiType)
|
||||||
JS_SetReservedSlot(typeObj, SLOT_FFITYPE, PRIVATE_TO_JSVAL(ffiType));
|
JS_SetReservedSlot(typeObj, SLOT_FFITYPE, PRIVATE_TO_JSVAL(ffiType));
|
||||||
if (name)
|
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_SIZE, size);
|
||||||
JS_SetReservedSlot(typeObj, SLOT_ALIGN, align);
|
JS_SetReservedSlot(typeObj, SLOT_ALIGN, align);
|
||||||
|
|
||||||
|
@ -4291,7 +4291,7 @@ CType::GetName(JSContext* cx, HandleObject obj)
|
||||||
JSString* name = BuildTypeName(cx, obj);
|
JSString* name = BuildTypeName(cx, obj);
|
||||||
if (!name)
|
if (!name)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
JS_SetReservedSlot(obj, SLOT_NAME, STRING_TO_JSVAL(name));
|
JS_SetReservedSlot(obj, SLOT_NAME, StringValue(name));
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7086,7 +7086,7 @@ CData::Create(JSContext* cx,
|
||||||
JS_SetReservedSlot(dataObj, SLOT_REFERENT, OBJECT_TO_JSVAL(refObj));
|
JS_SetReservedSlot(dataObj, SLOT_REFERENT, OBJECT_TO_JSVAL(refObj));
|
||||||
|
|
||||||
// Set our ownership flag.
|
// 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
|
// attach the buffer. since it might not be 2-byte aligned, we need to
|
||||||
// allocate an aligned space for it and store it there. :(
|
// allocate an aligned space for it and store it there. :(
|
||||||
|
|
|
@ -28,7 +28,7 @@ FRAGMENT(Root, handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FRAGMENT(Root, HeapSlot) {
|
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)));
|
JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, JS::HandleValueArray(plinth)));
|
||||||
|
|
||||||
breakpoint();
|
breakpoint();
|
||||||
|
|
|
@ -74,26 +74,26 @@ BEGIN_TEST(testParseJSON_success)
|
||||||
const char16_t emptystr[] = { '\0' };
|
const char16_t emptystr[] = { '\0' };
|
||||||
str = js::NewStringCopyN<CanGC>(cx, emptystr, 0);
|
str = js::NewStringCopyN<CanGC>(cx, emptystr, 0);
|
||||||
CHECK(str);
|
CHECK(str);
|
||||||
expected = STRING_TO_JSVAL(str);
|
expected = JS::StringValue(str);
|
||||||
CHECK(TryParse(cx, "\"\"", expected));
|
CHECK(TryParse(cx, "\"\"", expected));
|
||||||
|
|
||||||
const char16_t nullstr[] = { '\0' };
|
const char16_t nullstr[] = { '\0' };
|
||||||
str = NewString(cx, nullstr);
|
str = NewString(cx, nullstr);
|
||||||
CHECK(str);
|
CHECK(str);
|
||||||
expected = STRING_TO_JSVAL(str);
|
expected = JS::StringValue(str);
|
||||||
CHECK(TryParse(cx, "\"\\u0000\"", expected));
|
CHECK(TryParse(cx, "\"\\u0000\"", expected));
|
||||||
|
|
||||||
const char16_t backstr[] = { '\b' };
|
const char16_t backstr[] = { '\b' };
|
||||||
str = NewString(cx, backstr);
|
str = NewString(cx, backstr);
|
||||||
CHECK(str);
|
CHECK(str);
|
||||||
expected = STRING_TO_JSVAL(str);
|
expected = JS::StringValue(str);
|
||||||
CHECK(TryParse(cx, "\"\\b\"", expected));
|
CHECK(TryParse(cx, "\"\\b\"", expected));
|
||||||
CHECK(TryParse(cx, "\"\\u0008\"", expected));
|
CHECK(TryParse(cx, "\"\\u0008\"", expected));
|
||||||
|
|
||||||
const char16_t newlinestr[] = { '\n', };
|
const char16_t newlinestr[] = { '\n', };
|
||||||
str = NewString(cx, newlinestr);
|
str = NewString(cx, newlinestr);
|
||||||
CHECK(str);
|
CHECK(str);
|
||||||
expected = STRING_TO_JSVAL(str);
|
expected = JS::StringValue(str);
|
||||||
CHECK(TryParse(cx, "\"\\n\"", expected));
|
CHECK(TryParse(cx, "\"\\n\"", expected));
|
||||||
CHECK(TryParse(cx, "\"\\u000A\"", expected));
|
CHECK(TryParse(cx, "\"\\u000A\"", expected));
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ JS_GetPositiveInfinityValue(JSContext* cx)
|
||||||
JS_PUBLIC_API(jsval)
|
JS_PUBLIC_API(jsval)
|
||||||
JS_GetEmptyStringValue(JSContext* cx)
|
JS_GetEmptyStringValue(JSContext* cx)
|
||||||
{
|
{
|
||||||
return STRING_TO_JSVAL(cx->runtime()->emptyString);
|
return StringValue(cx->runtime()->emptyString);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSString*)
|
JS_PUBLIC_API(JSString*)
|
||||||
|
|
|
@ -3532,7 +3532,7 @@ XPCJSRuntime::OnJSContextNew(JSContext* cx)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mStrIDs[i] = INTERNED_STRING_TO_JSID(cx, str);
|
mStrIDs[i] = INTERNED_STRING_TO_JSID(cx, str);
|
||||||
mStrJSVals[i] = STRING_TO_JSVAL(str);
|
mStrJSVals[i].setString(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mozilla::dom::DefineStaticJSVals(cx)) {
|
if (!mozilla::dom::DefineStaticJSVals(cx)) {
|
||||||
|
|
|
@ -115,7 +115,7 @@ private:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
rval.set(STRING_TO_JSVAL(ucstr));
|
rval.setString(ucstr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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());
|
JS_ReportError(cx, "can't set envariable %s to %s", name.ptr(), value.ptr());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
vp.set(STRING_TO_JSVAL(valstr));
|
vp.setString(valstr);
|
||||||
#endif /* !defined SOLARIS */
|
#endif /* !defined SOLARIS */
|
||||||
return result.succeed();
|
return result.succeed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ ToStringGuts(XPCCallContext& ccx)
|
||||||
if (!str)
|
if (!str)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ccx.SetRetVal(STRING_TO_JSVAL(str));
|
ccx.SetRetVal(JS::StringValue(str));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ stepFunc(JSContext *aCtx,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*_vp = BOOLEAN_TO_JSVAL(hasMore);
|
_vp->setBoolean(hasMore);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ StatementRow::GetProperty(nsIXPConnectWrappedNative *aWrapper,
|
||||||
*_retval = false;
|
*_retval = false;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
*_vp = STRING_TO_JSVAL(str);
|
_vp->setString(str);
|
||||||
}
|
}
|
||||||
else if (type == mozIStorageValueArray::VALUE_TYPE_BLOB) {
|
else if (type == mozIStorageValueArray::VALUE_TYPE_BLOB) {
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче