diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 504859fc3b5..c11c0d27c88 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -3844,8 +3844,7 @@ nsStorage2SH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, return NS_OK; } - nsTArray *keys = - (nsTArray *)JSVAL_TO_PRIVATE(*statep); + nsTArray *keys = (nsTArray *)statep->toPrivate(); if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) { nsString& key = keys->ElementAt(0); diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index 859f6cd4fc6..aa8aab4813f 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -1498,7 +1498,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JS::Handle obj, JSIterateOp break; case JSENUMERATE_NEXT: - state = (NPObjectEnumerateState *)JSVAL_TO_PRIVATE(*statep); + state = (NPObjectEnumerateState *)statep->toPrivate(); enum_value = state->value; length = state->length; if (state->index != length) { @@ -1509,7 +1509,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JS::Handle obj, JSIterateOp // FALL THROUGH case JSENUMERATE_DESTROY: - state = (NPObjectEnumerateState *)JSVAL_TO_PRIVATE(*statep); + state = (NPObjectEnumerateState *)statep->toPrivate(); if (state->value) PR_Free(state->value); delete state; diff --git a/dom/xbl/nsXBLBinding.cpp b/dom/xbl/nsXBLBinding.cpp index 379c2495fb0..634f57d6ef0 100644 --- a/dom/xbl/nsXBLBinding.cpp +++ b/dom/xbl/nsXBLBinding.cpp @@ -780,7 +780,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen JS::Value protoBinding = ::JS_GetReservedSlot(proto, 0); - if (JSVAL_TO_PRIVATE(protoBinding) != mPrototypeBinding) { + if (protoBinding.toPrivate() != mPrototypeBinding) { // Not the right binding continue; } diff --git a/js/jsd/jsd_scpt.cpp b/js/jsd/jsd_scpt.cpp index ff542f6cf94..995ccbeb445 100644 --- a/js/jsd/jsd_scpt.cpp +++ b/js/jsd/jsd_scpt.cpp @@ -706,7 +706,7 @@ jsd_TrapHandler(JSContext *cx, JSScript *script_, jsbytecode *pc, jsval *rval, jsval closure) { JS::RootedScript script(cx, script_); - JSDExecHook* jsdhook = (JSDExecHook*) JSVAL_TO_PRIVATE(closure); + JSDExecHook* jsdhook = (JSDExecHook*) closure.toPrivate(); JSD_ExecutionHookProc hook; void* hookData; JSDContext* jsdc; diff --git a/js/public/Value.h b/js/public/Value.h index 30ca07ce580..6fb6fcd910d 100644 --- a/js/public/Value.h +++ b/js/public/Value.h @@ -1882,13 +1882,6 @@ PRIVATE_TO_JSVAL(void *ptr) return IMPL_TO_JSVAL(PRIVATE_PTR_TO_JSVAL_IMPL(ptr)); } -static inline void * -JSVAL_TO_PRIVATE(jsval v) -{ - MOZ_ASSERT(v.isDouble()); - return JSVAL_TO_PRIVATE_PTR_IMPL(JSVAL_TO_IMPL(v)); -} - // JS constants. For efficiency, prefer predicates (e.g. v.isNull()) and // constructing values from scratch (e.g. Int32Value(0)). These constants are // stored in memory and initialized at startup, so testing against them and diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index c5d18589eda..aeff10e83bd 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -1289,7 +1289,7 @@ GetCallbacks(JSObject* obj) if (result.isUndefined()) return nullptr; - return static_cast(JSVAL_TO_PRIVATE(result)); + return static_cast(result.toPrivate()); } // Utility function to access a property of an object as an object @@ -1388,7 +1388,7 @@ SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf, JSObject *obj) bool owns = slot.toBoolean(); slot = JS_GetReservedSlot(obj, ctypes::SLOT_DATA); if (!slot.isUndefined()) { - char** buffer = static_cast(JSVAL_TO_PRIVATE(slot)); + char** buffer = static_cast(slot.toPrivate()); n += mallocSizeOf(buffer); if (owns) n += mallocSizeOf(*buffer); @@ -3299,7 +3299,7 @@ CType::Finalize(JSFreeOp *fop, JSObject* obj) // Free the FunctionInfo. slot = JS_GetReservedSlot(obj, SLOT_FNINFO); if (!slot.isUndefined()) - FreeOp::get(fop)->delete_(static_cast(JSVAL_TO_PRIVATE(slot))); + FreeOp::get(fop)->delete_(static_cast(slot.toPrivate())); break; } @@ -3307,7 +3307,7 @@ CType::Finalize(JSFreeOp *fop, JSObject* obj) // Free the FieldInfoHash table. slot = JS_GetReservedSlot(obj, SLOT_FIELDINFO); if (!slot.isUndefined()) { - void* info = JSVAL_TO_PRIVATE(slot); + void* info = slot.toPrivate(); FreeOp::get(fop)->delete_(static_cast(info)); } } @@ -3317,7 +3317,7 @@ CType::Finalize(JSFreeOp *fop, JSObject* obj) // Free the ffi_type info. slot = JS_GetReservedSlot(obj, SLOT_FFITYPE); if (!slot.isUndefined()) { - ffi_type* ffiType = static_cast(JSVAL_TO_PRIVATE(slot)); + ffi_type* ffiType = static_cast(slot.toPrivate()); FreeOp::get(fop)->free_(ffiType->elements); FreeOp::get(fop)->delete_(ffiType); } @@ -3345,8 +3345,7 @@ CType::Trace(JSTracer* trc, JSObject* obj) if (slot.isUndefined()) return; - FieldInfoHash* fields = - static_cast(JSVAL_TO_PRIVATE(slot)); + FieldInfoHash* fields = static_cast(slot.toPrivate()); for (FieldInfoHash::Enum e(*fields); !e.empty(); e.popFront()) { JSString *key = e.front().key(); JS_CallStringTracer(trc, &key, "fieldName"); @@ -3363,7 +3362,7 @@ CType::Trace(JSTracer* trc, JSObject* obj) if (slot.isUndefined()) return; - FunctionInfo* fninfo = static_cast(JSVAL_TO_PRIVATE(slot)); + FunctionInfo* fninfo = static_cast(slot.toPrivate()); JS_ASSERT(fninfo); // Identify our objects to the tracer. @@ -3539,7 +3538,7 @@ CType::GetFFIType(JSContext* cx, JSObject* obj) jsval slot = JS_GetReservedSlot(obj, SLOT_FFITYPE); if (!slot.isUndefined()) { - return static_cast(JSVAL_TO_PRIVATE(slot)); + return static_cast(slot.toPrivate()); } AutoPtr result; @@ -5090,9 +5089,9 @@ StructType::GetFieldInfo(JSObject* obj) JS_ASSERT(CType::GetTypeCode(obj) == TYPE_struct); jsval slot = JS_GetReservedSlot(obj, SLOT_FIELDINFO); - JS_ASSERT(!slot.isUndefined() && JSVAL_TO_PRIVATE(slot)); + JS_ASSERT(!slot.isUndefined() && slot.toPrivate()); - return static_cast(JSVAL_TO_PRIVATE(slot)); + return static_cast(slot.toPrivate()); } const FieldInfo* @@ -5906,9 +5905,9 @@ FunctionType::GetFunctionInfo(JSObject* obj) JS_ASSERT(CType::GetTypeCode(obj) == TYPE_function); jsval slot = JS_GetReservedSlot(obj, SLOT_FNINFO); - JS_ASSERT(!slot.isUndefined() && JSVAL_TO_PRIVATE(slot)); + JS_ASSERT(!slot.isUndefined() && slot.toPrivate()); - return static_cast(JSVAL_TO_PRIVATE(slot)); + return static_cast(slot.toPrivate()); } bool @@ -6089,7 +6088,7 @@ CClosure::Trace(JSTracer* trc, JSObject* obj) if (slot.isUndefined()) return; - ClosureInfo* cinfo = static_cast(JSVAL_TO_PRIVATE(slot)); + ClosureInfo* cinfo = static_cast(slot.toPrivate()); // Identify our objects to the tracer. (There's no need to identify // 'closureObj', since that's us.) @@ -6107,7 +6106,7 @@ CClosure::Finalize(JSFreeOp *fop, JSObject* obj) if (slot.isUndefined()) return; - ClosureInfo* cinfo = static_cast(JSVAL_TO_PRIVATE(slot)); + ClosureInfo* cinfo = static_cast(slot.toPrivate()); FreeOp::get(fop)->delete_(cinfo); } @@ -6356,7 +6355,7 @@ CData::Finalize(JSFreeOp *fop, JSObject* obj) slot = JS_GetReservedSlot(obj, SLOT_DATA); if (slot.isUndefined()) return; - char** buffer = static_cast(JSVAL_TO_PRIVATE(slot)); + char** buffer = static_cast(slot.toPrivate()); if (owns) FreeOp::get(fop)->free_(*buffer); @@ -6381,7 +6380,7 @@ CData::GetData(JSObject* dataObj) jsval slot = JS_GetReservedSlot(dataObj, SLOT_DATA); - void** buffer = static_cast(JSVAL_TO_PRIVATE(slot)); + void** buffer = static_cast(slot.toPrivate()); JS_ASSERT(buffer); JS_ASSERT(*buffer); return *buffer; @@ -7300,7 +7299,7 @@ Int64Base::Finalize(JSFreeOp *fop, JSObject* obj) if (slot.isUndefined()) return; - FreeOp::get(fop)->delete_(static_cast(JSVAL_TO_PRIVATE(slot))); + FreeOp::get(fop)->delete_(static_cast(slot.toPrivate())); } uint64_t @@ -7308,7 +7307,7 @@ Int64Base::GetInt(JSObject* obj) { JS_ASSERT(Int64::IsInt64(obj) || UInt64::IsUInt64(obj)); jsval slot = JS_GetReservedSlot(obj, SLOT_INT64); - return *static_cast(JSVAL_TO_PRIVATE(slot)); + return *static_cast(slot.toPrivate()); } bool diff --git a/js/src/ctypes/Library.cpp b/js/src/ctypes/Library.cpp index 0821a3aafaa..a15b3bc9006 100644 --- a/js/src/ctypes/Library.cpp +++ b/js/src/ctypes/Library.cpp @@ -178,7 +178,7 @@ Library::GetLibrary(JSObject* obj) JS_ASSERT(IsLibrary(obj)); jsval slot = JS_GetReservedSlot(obj, SLOT_LIBRARY); - return static_cast(JSVAL_TO_PRIVATE(slot)); + return static_cast(slot.toPrivate()); } static void diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 613960e3bce..9390976e676 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -764,7 +764,7 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper, { nsCOMPtr isup; bool hasMore; - e = (nsISimpleEnumerator*) JSVAL_TO_PRIVATE(*statep); + e = (nsISimpleEnumerator*) statep->toPrivate(); if (NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore && NS_SUCCEEDED(e->GetNext(getter_AddRefs(isup))) && isup) { @@ -786,7 +786,7 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper, case JSENUMERATE_DESTROY: default: - e = (nsISimpleEnumerator*) JSVAL_TO_PRIVATE(*statep); + e = (nsISimpleEnumerator*) statep->toPrivate(); NS_IF_RELEASE(e); *statep = JSVAL_NULL; return NS_OK; @@ -1004,7 +1004,7 @@ nsXPCComponents_ClassesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper, { nsCOMPtr isup; bool hasMore; - e = (nsISimpleEnumerator*) JSVAL_TO_PRIVATE(*statep); + e = (nsISimpleEnumerator*) statep->toPrivate(); if (NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore && NS_SUCCEEDED(e->GetNext(getter_AddRefs(isup))) && isup) { @@ -1027,7 +1027,7 @@ nsXPCComponents_ClassesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper, case JSENUMERATE_DESTROY: default: - e = (nsISimpleEnumerator*) JSVAL_TO_PRIVATE(*statep); + e = (nsISimpleEnumerator*) statep->toPrivate(); NS_IF_RELEASE(e); *statep = JSVAL_NULL; return NS_OK; @@ -1264,7 +1264,7 @@ nsXPCComponents_Results::NewEnumerate(nsIXPConnectWrappedNative *wrapper, case JSENUMERATE_NEXT: { const char* name; - iter = (const void**) JSVAL_TO_PRIVATE(*statep); + iter = (const void**) statep->toPrivate(); if (nsXPCException::IterateNSResults(nullptr, &name, nullptr, iter)) { RootedString idstr(cx, JS_NewStringCopyZ(cx, name)); JS::RootedId id(cx); @@ -1278,7 +1278,7 @@ nsXPCComponents_Results::NewEnumerate(nsIXPConnectWrappedNative *wrapper, case JSENUMERATE_DESTROY: default: - iter = (const void**) JSVAL_TO_PRIVATE(*statep); + iter = (const void**) statep->toPrivate(); delete [] (char*) iter; *statep = JSVAL_NULL; return NS_OK; diff --git a/js/xpconnect/src/XPCWrappedNativeInfo.cpp b/js/xpconnect/src/XPCWrappedNativeInfo.cpp index 01321fc2eae..0123a354efa 100644 --- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp +++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp @@ -30,8 +30,8 @@ XPCNativeMember::GetCallInfo(JSObject* funobj, jsval ifaceVal = js::GetFunctionNativeReserved(funobj, 0); jsval memberVal = js::GetFunctionNativeReserved(funobj, 1); - *pInterface = (XPCNativeInterface*) JSVAL_TO_PRIVATE(ifaceVal); - *pMember = (XPCNativeMember*) JSVAL_TO_PRIVATE(memberVal); + *pInterface = (XPCNativeInterface*) ifaceVal.toPrivate(); + *pMember = (XPCNativeMember*) memberVal.toPrivate(); return true; }