Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Backed out changesets ad58c270ce87 and 849151330d60 (bug 1177892) for…
Browse files Browse the repository at this point in the history
… B2G bustage.

CLOSED TREE
  • Loading branch information
rvandermeulen committed Jun 30, 2015
1 parent 0655c1c commit 7b24e24
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 45 deletions.
2 changes: 1 addition & 1 deletion dom/base/EventSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ EventSource::DispatchAllMessageEvents()
message->mData.Length());
NS_ENSURE_TRUE_VOID(jsString);

jsData.setString(jsString);
jsData = STRING_TO_JSVAL(jsString);
}

// create an event that uses the MessageEvent interface,
Expand Down
2 changes: 1 addition & 1 deletion dom/base/WebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ WebSocket::CreateAndDispatchMessageEvent(JSContext* aCx,
jsString = JS_NewUCStringCopyN(aCx, utf16Data.get(), utf16Data.Length());
NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);

jsData.setString(jsString);
jsData = STRING_TO_JSVAL(jsString);
}

// create an event that uses the MessageEvent interface,
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsDOMDataChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.setString(jsString);
jsData = STRING_TO_JSVAL(jsString);
}

nsCOMPtr<nsIDOMEvent> event;
Expand Down
8 changes: 4 additions & 4 deletions dom/base/nsJSEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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->setString(str);
*aArgv = STRING_TO_JSVAL(str);

break;
}
Expand All @@ -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->setString(str);
*aArgv = STRING_TO_JSVAL(str);
break;
}
case nsISupportsPrimitive::TYPE_PRBOOL : {
Expand All @@ -960,7 +960,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)

p->GetData(&data);

aArgv->setBoolean(data);
*aArgv = BOOLEAN_TO_JSVAL(data);

break;
}
Expand Down Expand Up @@ -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->setString(str);
*aArgv = STRING_TO_JSVAL(str);

break;
}
Expand Down
2 changes: 1 addition & 1 deletion dom/bindings/BindingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3028,7 +3028,7 @@ CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
JSAutoCompartment ac(aCx, aGlobal);

{
js::SetReservedSlot(aGlobal, DOM_OBJECT_SLOT, JS::PrivateValue(aNative));
js::SetReservedSlot(aGlobal, DOM_OBJECT_SLOT, PRIVATE_TO_JSVAL(aNative));
NS_ADDREF(aNative);

aCache->SetWrapper(aGlobal);
Expand Down
2 changes: 1 addition & 1 deletion dom/mobilemessage/MobileMessageCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ MobileMessageCallback::NotifyGetSmscAddress(const nsAString& aSmscAddress)
return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
}

JS::Rooted<JS::Value> val(cx, JS::StringValue(smsc));
JS::Rooted<JS::Value> val(cx, STRING_TO_JSVAL(smsc));
return NotifySuccess(val);
}

Expand Down
4 changes: 2 additions & 2 deletions dom/plugins/base/nsJSNPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant)
case NPVariantType_Null :
return JS::NullValue();
case NPVariantType_Bool :
return JS::BooleanValue(NPVARIANT_TO_BOOLEAN(*variant));
return BOOLEAN_TO_JSVAL(NPVARIANT_TO_BOOLEAN(*variant));
case NPVariantType_Int32 :
{
// Don't use INT_TO_JSVAL directly to prevent bugs when dealing
Expand All @@ -509,7 +509,7 @@ NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant)
::JS_NewUCStringCopyN(cx, utf16String.get(), utf16String.Length());

if (str) {
return JS::StringValue(str);
return STRING_TO_JSVAL(str);
}

break;
Expand Down
6 changes: 3 additions & 3 deletions dom/system/OSFileConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, JS::StringValue(strValue));
JS::Rooted<JS::Value> valValue(cx, STRING_TO_JSVAL(strValue));
return JS_SetProperty(cx, aObject, aProperty, valValue);
}

Expand Down Expand Up @@ -891,7 +891,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
if (!strVersion){
return false;
}
JS::Rooted<JS::Value> valVersion(cx, JS::StringValue(strVersion));
JS::Rooted<JS::Value> valVersion(cx, STRING_TO_JSVAL(strVersion));
if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
return false;
}
Expand All @@ -907,7 +907,7 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
return false;
}

JS::Rooted<JS::Value> valVersion(cx, JS::StringValue(strVersion));
JS::Rooted<JS::Value> valVersion(cx, STRING_TO_JSVAL(strVersion));
if (!JS_SetProperty(cx, objSys, "Name", valVersion)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion dom/workers/XMLHttpRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,7 @@ XMLHttpRequest::GetResponse(JSContext* /* unused */,
return;
}

mStateData.mResponse.setString(str);
mStateData.mResponse = STRING_TO_JSVAL(str);
}
}

Expand Down
2 changes: 1 addition & 1 deletion dom/xbl/nsXBLBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx,
nsXBLDocumentInfo* docInfo = aProtoBinding->XBLDocumentInfo();
::JS_SetPrivate(proto, docInfo);
NS_ADDREF(docInfo);
JS_SetReservedSlot(proto, 0, JS::PrivateValue(aProtoBinding));
JS_SetReservedSlot(proto, 0, PRIVATE_TO_JSVAL(aProtoBinding));

// Next, enter the compartment of the property holder, wrap the proto, and
// stick it on.
Expand Down
2 changes: 1 addition & 1 deletion js/ipc/JavaScriptShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ JavaScriptShared::fromVariant(JSContext* cx, const JSVariant& from, MutableHandl
return true;

case JSVariant::Tbool:
to.setBoolean(from.get_bool());
to.set(BOOLEAN_TO_JSVAL(from.get_bool()));
return true;

case JSVariant::TnsString:
Expand Down
20 changes: 20 additions & 0 deletions js/public/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,12 @@ 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)
{
Expand All @@ -1979,6 +1985,20 @@ 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
PRIVATE_TO_JSVAL(void* ptr)
{
return IMPL_TO_JSVAL(PRIVATE_PTR_TO_JSVAL_IMPL(ptr));
}

namespace JS {

extern JS_PUBLIC_DATA(const HandleValue) NullHandleValue;
Expand Down
22 changes: 11 additions & 11 deletions js/src/ctypes/CTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@ JS_SetCTypesCallbacks(JSObject* ctypesObj, const JSCTypesCallbacks* callbacks)

// Set the callbacks on a reserved slot.
JS_SetReservedSlot(ctypesObj, SLOT_CALLBACKS,
PrivateValue(const_cast<JSCTypesCallbacks*>(callbacks)));
PRIVATE_TO_JSVAL(const_cast<JSCTypesCallbacks*>(callbacks)));
}

namespace js {
Expand Down Expand Up @@ -3929,9 +3929,9 @@ CType::Create(JSContext* cx,
// Set up the reserved slots.
JS_SetReservedSlot(typeObj, SLOT_TYPECODE, INT_TO_JSVAL(type));
if (ffiType)
JS_SetReservedSlot(typeObj, SLOT_FFITYPE, PrivateValue(ffiType));
JS_SetReservedSlot(typeObj, SLOT_FFITYPE, PRIVATE_TO_JSVAL(ffiType));
if (name)
JS_SetReservedSlot(typeObj, SLOT_NAME, StringValue(name));
JS_SetReservedSlot(typeObj, SLOT_NAME, STRING_TO_JSVAL(name));
JS_SetReservedSlot(typeObj, SLOT_SIZE, size);
JS_SetReservedSlot(typeObj, SLOT_ALIGN, align);

Expand Down Expand Up @@ -4274,7 +4274,7 @@ CType::GetFFIType(JSContext* cx, JSObject* obj)

if (!result)
return nullptr;
JS_SetReservedSlot(obj, SLOT_FFITYPE, PrivateValue(result.get()));
JS_SetReservedSlot(obj, SLOT_FFITYPE, PRIVATE_TO_JSVAL(result.get()));
return result.release();
}

Expand All @@ -4291,7 +4291,7 @@ CType::GetName(JSContext* cx, HandleObject obj)
JSString* name = BuildTypeName(cx, obj);
if (!name)
return nullptr;
JS_SetReservedSlot(obj, SLOT_NAME, StringValue(name));
JS_SetReservedSlot(obj, SLOT_NAME, STRING_TO_JSVAL(name));
return name;
}

Expand Down Expand Up @@ -5636,7 +5636,7 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj_, JSObject* fieldsOb
if (!SizeTojsval(cx, structSize, &sizeVal))
return false;

JS_SetReservedSlot(typeObj, SLOT_FIELDINFO, PrivateValue(fields.release()));
JS_SetReservedSlot(typeObj, SLOT_FIELDINFO, PRIVATE_TO_JSVAL(fields.release()));

JS_SetReservedSlot(typeObj, SLOT_SIZE, sizeVal);
JS_SetReservedSlot(typeObj, SLOT_ALIGN, INT_TO_JSVAL(structAlign));
Expand Down Expand Up @@ -6297,7 +6297,7 @@ CreateFunctionInfo(JSContext* cx,
}

// Stash the FunctionInfo in a reserved slot.
JS_SetReservedSlot(typeObj, SLOT_FNINFO, PrivateValue(fninfo));
JS_SetReservedSlot(typeObj, SLOT_FNINFO, PRIVATE_TO_JSVAL(fninfo));

ffi_abi abi;
if (!GetABI(cx, abiType, &abi)) {
Expand Down Expand Up @@ -6840,7 +6840,7 @@ CClosure::Create(JSContext* cx,
cinfo->jsfnObj = fnObj;

// Stash the ClosureInfo struct on our new object.
JS_SetReservedSlot(result, SLOT_CLOSUREINFO, PrivateValue(cinfo));
JS_SetReservedSlot(result, SLOT_CLOSUREINFO, PRIVATE_TO_JSVAL(cinfo));

// Create an ffi_closure object and initialize it.
void* code;
Expand Down Expand Up @@ -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, BooleanValue(ownResult));
JS_SetReservedSlot(dataObj, SLOT_OWNS, BOOLEAN_TO_JSVAL(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. :(
Expand Down Expand Up @@ -7117,7 +7117,7 @@ CData::Create(JSContext* cx,
}

*buffer = data;
JS_SetReservedSlot(dataObj, SLOT_DATA, PrivateValue(buffer));
JS_SetReservedSlot(dataObj, SLOT_DATA, PRIVATE_TO_JSVAL(buffer));

return dataObj;
}
Expand Down Expand Up @@ -8061,7 +8061,7 @@ Int64Base::Construct(JSContext* cx,
return nullptr;
}

JS_SetReservedSlot(result, SLOT_INT64, PrivateValue(buffer));
JS_SetReservedSlot(result, SLOT_INT64, PRIVATE_TO_JSVAL(buffer));

if (!JS_FreezeObject(cx, result))
return nullptr;
Expand Down
6 changes: 3 additions & 3 deletions js/src/ctypes/Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Library::Create(JSContext* cx, jsval path_, const JSCTypesCallbacks* callbacks)
return nullptr;

// initialize the library
JS_SetReservedSlot(libraryObj, SLOT_LIBRARY, PrivateValue(nullptr));
JS_SetReservedSlot(libraryObj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(nullptr));

// attach API functions
if (!JS_DefineFunctions(cx, libraryObj, sLibraryFunctions))
Expand Down Expand Up @@ -166,7 +166,7 @@ Library::Create(JSContext* cx, jsval path_, const JSCTypesCallbacks* callbacks)
#endif

// stash the library
JS_SetReservedSlot(libraryObj, SLOT_LIBRARY, PrivateValue(library));
JS_SetReservedSlot(libraryObj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(library));

return libraryObj;
}
Expand Down Expand Up @@ -244,7 +244,7 @@ Library::Close(JSContext* cx, unsigned argc, jsval* vp)

// delete our internal objects
UnloadLibrary(obj);
JS_SetReservedSlot(obj, SLOT_LIBRARY, PrivateValue(nullptr));
JS_SetReservedSlot(obj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(nullptr));

args.rval().setUndefined();
return true;
Expand Down
2 changes: 1 addition & 1 deletion js/src/gdb/tests/test-Root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ FRAGMENT(Root, handle) {
}

FRAGMENT(Root, HeapSlot) {
JS::Rooted<jsval> plinth(cx, JS::StringValue(JS_NewStringCopyZ(cx, "plinth")));
JS::Rooted<jsval> plinth(cx, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, "plinth")));
JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, JS::HandleValueArray(plinth)));

breakpoint();
Expand Down
8 changes: 4 additions & 4 deletions js/src/jsapi-tests/testParseJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,26 @@ BEGIN_TEST(testParseJSON_success)
const char16_t emptystr[] = { '\0' };
str = js::NewStringCopyN<CanGC>(cx, emptystr, 0);
CHECK(str);
expected = JS::StringValue(str);
expected = STRING_TO_JSVAL(str);
CHECK(TryParse(cx, "\"\"", expected));

const char16_t nullstr[] = { '\0' };
str = NewString(cx, nullstr);
CHECK(str);
expected = JS::StringValue(str);
expected = STRING_TO_JSVAL(str);
CHECK(TryParse(cx, "\"\\u0000\"", expected));

const char16_t backstr[] = { '\b' };
str = NewString(cx, backstr);
CHECK(str);
expected = JS::StringValue(str);
expected = STRING_TO_JSVAL(str);
CHECK(TryParse(cx, "\"\\b\"", expected));
CHECK(TryParse(cx, "\"\\u0008\"", expected));

const char16_t newlinestr[] = { '\n', };
str = NewString(cx, newlinestr);
CHECK(str);
expected = JS::StringValue(str);
expected = STRING_TO_JSVAL(str);
CHECK(TryParse(cx, "\"\\n\"", expected));
CHECK(TryParse(cx, "\"\\u000A\"", expected));

Expand Down
2 changes: 1 addition & 1 deletion js/src/jsapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ JS_GetPositiveInfinityValue(JSContext* cx)
JS_PUBLIC_API(jsval)
JS_GetEmptyStringValue(JSContext* cx)
{
return StringValue(cx->runtime()->emptyString);
return STRING_TO_JSVAL(cx->runtime()->emptyString);
}

JS_PUBLIC_API(JSString*)
Expand Down
2 changes: 1 addition & 1 deletion js/src/shell/js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5436,7 +5436,7 @@ static void
InitDOMObject(HandleObject obj)
{
/* Fow now just initialize to a constant we can check. */
SetReservedSlot(obj, DOM_OBJECT_SLOT, PrivateValue((void*)0x1234));
SetReservedSlot(obj, DOM_OBJECT_SLOT, PRIVATE_TO_JSVAL((void*)0x1234));
}

static bool
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/src/XPCJSRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3532,7 +3532,7 @@ XPCJSRuntime::OnJSContextNew(JSContext* cx)
return false;
}
mStrIDs[i] = INTERNED_STRING_TO_JSID(cx, str);
mStrJSVals[i].setString(str);
mStrJSVals[i] = STRING_TO_JSVAL(str);
}

if (!mozilla::dom::DefineStaticJSVals(cx)) {
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/src/XPCLocale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct XPCLocaleCallbacks : public JSLocaleCallbacks
return false;
}

rval.setString(ucstr);
rval.set(STRING_TO_JSVAL(ucstr));
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/src/XPCShellImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.setString(valstr);
vp.set(STRING_TO_JSVAL(valstr));
#endif /* !defined SOLARIS */
return result.succeed();
}
Expand Down
Loading

0 comments on commit 7b24e24

Please sign in to comment.