mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 952650 (part 12) - Remove JSVAL_TO_OBJECT. r=till.
--HG-- extra : rebase_source : 60dcaa2b778d3cf6eb7dc1a4949aab010ed8c130
This commit is contained in:
parent
3a5329b969
commit
530542eecd
@ -12155,7 +12155,7 @@ nsIDocument::WrapObject(JSContext *aCx)
|
||||
|
||||
NS_NAMED_LITERAL_STRING(doc_str, "document");
|
||||
|
||||
if (!JS_DefineUCProperty(aCx, JSVAL_TO_OBJECT(winVal), doc_str.get(),
|
||||
if (!JS_DefineUCProperty(aCx, winVal.toObjectOrNull(), doc_str.get(),
|
||||
doc_str.Length(), JS::ObjectValue(*obj),
|
||||
JS_PropertyStub, JS_StrictPropertyStub,
|
||||
JSPROP_READONLY | JSPROP_ENUMERATE)) {
|
||||
|
@ -2451,7 +2451,7 @@ GetRequestBody(nsIVariant* aBody, nsIInputStream** aResult, uint64_t* aContentLe
|
||||
|
||||
nsresult rv = aBody->GetAsJSVal(&realVal);
|
||||
if (NS_SUCCEEDED(rv) && !JSVAL_IS_PRIMITIVE(realVal)) {
|
||||
JS::Rooted<JSObject*> obj(cx, JSVAL_TO_OBJECT(realVal));
|
||||
JS::Rooted<JSObject*> obj(cx, realVal.toObjectOrNull());
|
||||
if (JS_IsArrayBufferObject(obj)) {
|
||||
ArrayBuffer buf(obj);
|
||||
return GetRequestBody(buf.Data(), buf.Length(), aResult,
|
||||
|
@ -107,7 +107,7 @@ JSValToDashArray(JSContext* cx, const JS::Value& patternArray,
|
||||
static const uint32_t MAX_NUM_DASHES = 1 << 14;
|
||||
|
||||
if (!JSVAL_IS_PRIMITIVE(patternArray)) {
|
||||
JS::Rooted<JSObject*> obj(cx, JSVAL_TO_OBJECT(patternArray));
|
||||
JS::Rooted<JSObject*> obj(cx, patternArray.toObjectOrNull());
|
||||
uint32_t length;
|
||||
if (!JS_GetArrayLength(cx, obj, &length)) {
|
||||
// Not an array-like thing
|
||||
|
@ -1392,7 +1392,7 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
|
||||
rv = nsContentUtils::WrapNative(jscontext, mRoot, mRoot, &v);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JS::Rooted<JSObject*> jselement(jscontext, JSVAL_TO_OBJECT(v));
|
||||
JS::Rooted<JSObject*> jselement(jscontext, v.toObjectOrNull());
|
||||
|
||||
if (mDB) {
|
||||
// database
|
||||
|
@ -109,7 +109,7 @@ PostMessageReadStructuredClone(JSContext* cx,
|
||||
if (JS_ReadBytes(reader, &supports, sizeof(supports))) {
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, supports, &val))) {
|
||||
return JSVAL_TO_OBJECT(val);
|
||||
return val.toObjectOrNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2390,7 +2390,7 @@ nsDOMWindowUtils::GetClassName(JS::Handle<JS::Value> aObject, JSContext* aCx,
|
||||
return NS_ERROR_XPC_BAD_CONVERT_JS;
|
||||
}
|
||||
|
||||
*aName = NS_strdup(JS_GetClass(JSVAL_TO_OBJECT(aObject))->name);
|
||||
*aName = NS_strdup(JS_GetClass(aObject.toObjectOrNull())->name);
|
||||
NS_ABORT_IF_FALSE(*aName, "NS_strdup should be infallible.");
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3213,7 +3213,7 @@ nsDOMWindowUtils::GetFileId(JS::Handle<JS::Value> aFile, JSContext* aCx,
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_PRIMITIVE(aFile)) {
|
||||
JSObject* obj = JSVAL_TO_OBJECT(aFile);
|
||||
JSObject* obj = aFile.toObjectOrNull();
|
||||
|
||||
file::FileHandle* fileHandle;
|
||||
if (NS_SUCCEEDED(UNWRAP_OBJECT(FileHandle, obj, fileHandle))) {
|
||||
|
@ -837,7 +837,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return JSVAL_TO_OBJECT(wrappedBlob);
|
||||
return wrappedBlob.toObjectOrNull();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMFile> domFile;
|
||||
@ -862,7 +862,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return JSVAL_TO_OBJECT(wrappedFile);
|
||||
return wrappedFile.toObjectOrNull();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -655,7 +655,7 @@ IndexedDatabaseManager::InitWindowless(JS::Handle<JS::Value> aGlobal, JSContext*
|
||||
{
|
||||
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
JS::Rooted<JSObject*> global(aCx, JSVAL_TO_OBJECT(aGlobal));
|
||||
JS::Rooted<JSObject*> global(aCx, aGlobal.toObjectOrNull());
|
||||
if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
|
||||
NS_WARNING("Passed object is not a global object!");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -96,7 +96,7 @@ GetJSValFromKeyPathString(JSContext* aCx,
|
||||
nsString targetObjectPropName;
|
||||
JS::Rooted<JSObject*> targetObject(aCx, nullptr);
|
||||
JS::Rooted<JSObject*> obj(aCx,
|
||||
JSVAL_IS_PRIMITIVE(aValue) ? nullptr : JSVAL_TO_OBJECT(aValue));
|
||||
JSVAL_IS_PRIMITIVE(aValue) ? nullptr : aValue.toObjectOrNull());
|
||||
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
const nsDependentSubstring& token = tokenizer.nextToken();
|
||||
@ -132,7 +132,7 @@ GetJSValFromKeyPathString(JSContext* aCx,
|
||||
if (JSVAL_IS_PRIMITIVE(intermediate)) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
||||
}
|
||||
obj = JSVAL_TO_OBJECT(intermediate);
|
||||
obj = intermediate.toObjectOrNull();
|
||||
}
|
||||
else {
|
||||
// ...otherwise use it as key
|
||||
@ -272,7 +272,7 @@ KeyPath::Parse(JSContext* aCx, const JS::Value& aValue_, KeyPath* aKeyPath)
|
||||
// See if this is a JS array.
|
||||
if (JS_IsArrayObject(aCx, aValue)) {
|
||||
|
||||
JS::Rooted<JSObject*> obj(aCx, JSVAL_TO_OBJECT(aValue));
|
||||
JS::Rooted<JSObject*> obj(aCx, aValue.toObjectOrNull());
|
||||
|
||||
uint32_t length;
|
||||
if (!JS_GetArrayLength(aCx, obj, &length)) {
|
||||
|
@ -435,7 +435,7 @@ JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant)
|
||||
JS::Rooted<JSObject*> obj(cx, val.toObjectOrNull());
|
||||
obj = js::CheckedUnwrap(obj);
|
||||
if (!obj) {
|
||||
obj = JSVAL_TO_OBJECT(val);
|
||||
obj = val.toObjectOrNull();
|
||||
}
|
||||
|
||||
NPObject *npobj = nsJSObjWrapper::GetNewOrUsed(npp, cx, obj);
|
||||
@ -594,7 +594,7 @@ nsJSObjWrapper::NP_HasMethod(NPObject *npobj, NPIdentifier id)
|
||||
bool ok = GetProperty(cx, npjsobj->mJSObj, id, &v);
|
||||
|
||||
return ok && !JSVAL_IS_PRIMITIVE(v) &&
|
||||
::JS_ObjectIsFunction(cx, JSVAL_TO_OBJECT(v));
|
||||
::JS_ObjectIsFunction(cx, v.toObjectOrNull());
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -1352,7 +1352,7 @@ CallNPMethodInternal(JSContext *cx, JS::Handle<JSObject*> obj, unsigned argc,
|
||||
NPVariant v;
|
||||
VOID_TO_NPVARIANT(v);
|
||||
|
||||
JSObject *funobj = JSVAL_TO_OBJECT(argv[-2]);
|
||||
JSObject *funobj = argv[-2].toObjectOrNull();
|
||||
bool ok;
|
||||
const char *msg = "Error calling method on NPObject!";
|
||||
|
||||
@ -1594,7 +1594,7 @@ NPObjWrapper_Convert(JSContext *cx, JS::Handle<JSObject*> obj, JSType hint, JS::
|
||||
JS::Rooted<JS::Value> v(cx, JSVAL_VOID);
|
||||
if (!JS_GetProperty(cx, obj, "toString", &v))
|
||||
return false;
|
||||
if (!JSVAL_IS_PRIMITIVE(v) && JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(v))) {
|
||||
if (!JSVAL_IS_PRIMITIVE(v) && JS_ObjectIsCallable(cx, v.toObjectOrNull())) {
|
||||
if (!JS_CallFunctionValue(cx, obj, v, JS::HandleValueArray::empty(), vp))
|
||||
return false;
|
||||
if (JSVAL_IS_PRIMITIVE(vp))
|
||||
|
@ -63,7 +63,7 @@ DefineChromeWorkerFunctions(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
|
||||
UnicodeToNative
|
||||
};
|
||||
|
||||
JS_SetCTypesCallbacks(JSVAL_TO_OBJECT(ctypes), &callbacks);
|
||||
JS_SetCTypesCallbacks(ctypes.toObjectOrNull(), &callbacks);
|
||||
}
|
||||
#endif // BUILD_CTYPES
|
||||
|
||||
|
@ -99,7 +99,7 @@ PostToNFC(JSContext* aCx,
|
||||
data = abs.ptr();
|
||||
size = abs.length();
|
||||
} else if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
JSObject* obj = JSVAL_TO_OBJECT(v);
|
||||
JSObject* obj = v.toObjectOrNull();
|
||||
if (!JS_IsTypedArrayObject(obj)) {
|
||||
JS_ReportError(aCx, "Object passed in wasn't a typed array");
|
||||
return false;
|
||||
|
@ -104,7 +104,7 @@ PostToRIL(JSContext *aCx,
|
||||
data = abs.ptr();
|
||||
size = abs.length();
|
||||
} else if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
JSObject *obj = JSVAL_TO_OBJECT(v);
|
||||
JSObject *obj = v.toObjectOrNull();
|
||||
if (!JS_IsTypedArrayObject(obj)) {
|
||||
JS_ReportError(aCx, "Object passed in wasn't a typed array");
|
||||
return false;
|
||||
|
@ -222,7 +222,7 @@ jsd_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj)
|
||||
JSDObject*
|
||||
jsd_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return jsd_GetJSDObjectForJSObject(jsdc, JSVAL_TO_OBJECT(jsdval->val));
|
||||
return jsd_GetJSDObjectForJSObject(jsdc, jsdval->val.toObjectOrNull());
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
|
@ -99,7 +99,7 @@ _callHook(JSDContext *jsdc, JSContext *cx, JSAbstractFramePtr frame, bool isCons
|
||||
JS::RootedValue newObj(cx);
|
||||
if (!frame.getThisValue(cx, &newObj))
|
||||
return false;
|
||||
jsd_Constructing(jsdc, cx, JSVAL_TO_OBJECT(newObj), frame);
|
||||
jsd_Constructing(jsdc, cx, newObj.toObjectOrNull(), frame);
|
||||
}
|
||||
|
||||
jsscript = frame.script();
|
||||
|
@ -116,7 +116,7 @@ jsd_IsValueFunction(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
AutoSafeJSContext cx; // NB: Actually unused.
|
||||
return !JSVAL_IS_PRIMITIVE(jsdval->val) &&
|
||||
JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(jsdval->val));
|
||||
JS_ObjectIsCallable(cx, jsdval->val.toObjectOrNull());
|
||||
}
|
||||
|
||||
bool
|
||||
@ -127,7 +127,7 @@ jsd_IsValueNative(JSDContext* jsdc, JSDValue* jsdval)
|
||||
|
||||
if(jsd_IsValueFunction(jsdc, jsdval))
|
||||
{
|
||||
JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(jsdval->val));
|
||||
JSAutoCompartment ac(cx, jsdval->val.toObjectOrNull());
|
||||
AutoSaveExceptionState as(cx);
|
||||
bool ok = false;
|
||||
fun = JSD_GetValueFunction(jsdc, jsdval);
|
||||
@ -185,7 +185,7 @@ jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval)
|
||||
}
|
||||
|
||||
/* Objects call JS_ValueToString in their own compartment. */
|
||||
scopeObj = !JSVAL_IS_PRIMITIVE(jsdval->val) ? JSVAL_TO_OBJECT(jsdval->val) : jsdc->glob;
|
||||
scopeObj = !JSVAL_IS_PRIMITIVE(jsdval->val) ? jsdval->val.toObjectOrNull() : jsdc->glob;
|
||||
{
|
||||
JSAutoCompartment ac(cx, scopeObj);
|
||||
AutoSaveExceptionState as(cx);
|
||||
@ -216,7 +216,7 @@ jsd_GetValueFunctionId(JSDContext* jsdc, JSDValue* jsdval)
|
||||
|
||||
if(!jsdval->funName && jsd_IsValueFunction(jsdc, jsdval))
|
||||
{
|
||||
JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(jsdval->val));
|
||||
JSAutoCompartment ac(cx, jsdval->val.toObjectOrNull());
|
||||
AutoSaveExceptionState as(cx);
|
||||
fun = JSD_GetValueFunction(jsdc, jsdval);
|
||||
if(!fun)
|
||||
@ -367,7 +367,7 @@ static bool _buildProps(JSDContext* jsdc, JSDValue* jsdval)
|
||||
if(JSVAL_IS_PRIMITIVE(jsdval->val))
|
||||
return false;
|
||||
|
||||
obj = JSVAL_TO_OBJECT(jsdval->val);
|
||||
obj = jsdval->val.toObjectOrNull();
|
||||
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
|
||||
@ -505,7 +505,7 @@ jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* nameStr)
|
||||
if(!JS_ValueToId(cx, nameval, &nameid))
|
||||
return nullptr;
|
||||
|
||||
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
|
||||
if(!(obj = jsdval->val.toObjectOrNull()))
|
||||
return nullptr;
|
||||
|
||||
JS::Rooted<JSPropertyDescriptor> desc(cx);
|
||||
@ -570,7 +570,7 @@ jsd_GetValueFunction(JSDContext* jsdc, JSDValue* jsdval)
|
||||
if (JSVAL_IS_PRIMITIVE(jsdval->val))
|
||||
return nullptr;
|
||||
|
||||
obj = js::UncheckedUnwrap(JSVAL_TO_OBJECT(jsdval->val));
|
||||
obj = js::UncheckedUnwrap(jsdval->val.toObjectOrNull());
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JS::RootedValue funval(cx, JS::ObjectValue(*obj));
|
||||
fun = JS_ValueToFunction(cx, funval);
|
||||
@ -590,7 +590,7 @@ jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval)
|
||||
SET_BIT_FLAG(jsdval->flags, GOT_PROTO);
|
||||
if(JSVAL_IS_PRIMITIVE(jsdval->val))
|
||||
return nullptr;
|
||||
obj = JSVAL_TO_OBJECT(jsdval->val);
|
||||
obj = jsdval->val.toObjectOrNull();
|
||||
if(!JS_GetPrototype(cx, obj, &proto))
|
||||
return nullptr;
|
||||
if(!proto)
|
||||
@ -614,7 +614,7 @@ jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval)
|
||||
SET_BIT_FLAG(jsdval->flags, GOT_PARENT);
|
||||
if(JSVAL_IS_PRIMITIVE(jsdval->val))
|
||||
return nullptr;
|
||||
obj = JSVAL_TO_OBJECT(jsdval->val);
|
||||
obj = jsdval->val.toObjectOrNull();
|
||||
{
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
parent = JS_GetParentOrScopeChain(cx, obj);
|
||||
@ -641,7 +641,7 @@ jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval)
|
||||
SET_BIT_FLAG(jsdval->flags, GOT_CTOR);
|
||||
if(JSVAL_IS_PRIMITIVE(jsdval->val))
|
||||
return nullptr;
|
||||
obj = JSVAL_TO_OBJECT(jsdval->val);
|
||||
obj = jsdval->val.toObjectOrNull();
|
||||
if(!JS_GetPrototype(cx, obj, &proto))
|
||||
return nullptr;
|
||||
if(!proto)
|
||||
@ -665,7 +665,7 @@ jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval)
|
||||
jsval val = jsdval->val;
|
||||
if(!jsdval->className && !JSVAL_IS_PRIMITIVE(val))
|
||||
{
|
||||
JS::RootedObject obj(jsdc->jsrt, JSVAL_TO_OBJECT(val));
|
||||
JS::RootedObject obj(jsdc->jsrt, val.toObjectOrNull());
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
jsdval->className = JS_GetDebugClassName(obj);
|
||||
@ -685,7 +685,7 @@ jsd_GetScriptForValue(JSDContext* jsdc, JSDValue* jsdval)
|
||||
return nullptr;
|
||||
|
||||
{
|
||||
JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(val));
|
||||
JSAutoCompartment ac(cx, val.toObjectOrNull());
|
||||
AutoSaveExceptionState as(cx);
|
||||
JS::RootedFunction fun(cx, JSD_GetValueFunction(jsdc, jsdval));
|
||||
if (fun)
|
||||
|
@ -388,7 +388,7 @@ CallArgsFromSp(unsigned argc, Value *sp)
|
||||
* take a const JS::CallArgs&.
|
||||
*/
|
||||
|
||||
#define JS_THIS_OBJECT(cx,vp) (JSVAL_TO_OBJECT(JS_THIS(cx,vp)))
|
||||
#define JS_THIS_OBJECT(cx,vp) (JS_THIS(cx,vp).toObjectOrNull())
|
||||
|
||||
/*
|
||||
* Note: if this method returns null, an error has occurred and must be
|
||||
|
@ -916,7 +916,6 @@ CanonicalizeNaN(double d)
|
||||
* provide similar functionality. But there are a few key differences. One
|
||||
* is that JS::Value gives null a separate type. Thus
|
||||
*
|
||||
* JSVAL_IS_OBJECT(v) === v.isObjectOrNull()
|
||||
* !JSVAL_IS_PRIMITIVE(v) === v.isObject()
|
||||
*
|
||||
* Also, to help prevent mistakenly boxing a nullable JSObject* as an object,
|
||||
@ -1864,13 +1863,6 @@ STRING_TO_JSVAL(JSString *str)
|
||||
return IMPL_TO_JSVAL(STRING_TO_JSVAL_IMPL(str));
|
||||
}
|
||||
|
||||
static inline JSObject *
|
||||
JSVAL_TO_OBJECT(jsval v)
|
||||
{
|
||||
MOZ_ASSERT(JSVAL_IS_OBJECT_OR_NULL_IMPL(JSVAL_TO_IMPL(v)));
|
||||
return JSVAL_TO_OBJECT_IMPL(JSVAL_TO_IMPL(v));
|
||||
}
|
||||
|
||||
static inline jsval
|
||||
OBJECT_TO_JSVAL(JSObject *obj)
|
||||
{
|
||||
|
@ -1308,7 +1308,7 @@ static bool GetObjectProperty(JSContext *cx, HandleObject obj,
|
||||
return false;
|
||||
}
|
||||
|
||||
result.set(JSVAL_TO_OBJECT(val));
|
||||
result.set(val.toObjectOrNull());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1616,7 +1616,7 @@ jsvalToInteger(JSContext* cx, jsval val, IntegerType* result)
|
||||
return ConvertExact(d, result);
|
||||
}
|
||||
if (!JSVAL_IS_PRIMITIVE(val)) {
|
||||
JSObject* obj = JSVAL_TO_OBJECT(val);
|
||||
JSObject* obj = val.toObjectOrNull();
|
||||
if (CData::IsCData(obj)) {
|
||||
JSObject* typeObj = CData::GetCType(obj);
|
||||
void* data = CData::GetData(obj);
|
||||
@ -1705,7 +1705,7 @@ jsvalToFloat(JSContext *cx, jsval val, FloatType* result)
|
||||
return true;
|
||||
}
|
||||
if (!JSVAL_IS_PRIMITIVE(val)) {
|
||||
JSObject* obj = JSVAL_TO_OBJECT(val);
|
||||
JSObject* obj = val.toObjectOrNull();
|
||||
if (CData::IsCData(obj)) {
|
||||
JSObject* typeObj = CData::GetCType(obj);
|
||||
void* data = CData::GetData(obj);
|
||||
@ -1829,7 +1829,7 @@ jsvalToBigInteger(JSContext* cx,
|
||||
}
|
||||
if (!JSVAL_IS_PRIMITIVE(val)) {
|
||||
// Allow conversion from an Int64 or UInt64 object directly.
|
||||
JSObject* obj = JSVAL_TO_OBJECT(val);
|
||||
JSObject* obj = val.toObjectOrNull();
|
||||
|
||||
if (UInt64::IsUInt64(obj)) {
|
||||
// Make sure the integer fits in IntegerType.
|
||||
@ -1952,7 +1952,7 @@ jsvalToIntegerExplicit(jsval val, IntegerType* result)
|
||||
}
|
||||
if (!JSVAL_IS_PRIMITIVE(val)) {
|
||||
// Convert Int64 and UInt64 values by C-style cast.
|
||||
JSObject* obj = JSVAL_TO_OBJECT(val);
|
||||
JSObject* obj = val.toObjectOrNull();
|
||||
if (Int64::IsInt64(obj)) {
|
||||
int64_t i = Int64Base::GetInt(obj);
|
||||
*result = IntegerType(i);
|
||||
@ -1996,7 +1996,7 @@ jsvalToPtrExplicit(JSContext* cx, jsval val, uintptr_t* result)
|
||||
return double(*result) == d;
|
||||
}
|
||||
if (!JSVAL_IS_PRIMITIVE(val)) {
|
||||
JSObject* obj = JSVAL_TO_OBJECT(val);
|
||||
JSObject* obj = val.toObjectOrNull();
|
||||
if (Int64::IsInt64(obj)) {
|
||||
int64_t i = Int64Base::GetInt(obj);
|
||||
intptr_t p = intptr_t(i);
|
||||
@ -2243,7 +2243,7 @@ ImplicitConvert(JSContext* cx,
|
||||
JSObject* sourceType = nullptr;
|
||||
RootedObject valObj(cx, nullptr);
|
||||
if (!JSVAL_IS_PRIMITIVE(val)) {
|
||||
valObj = JSVAL_TO_OBJECT(val);
|
||||
valObj = val.toObjectOrNull();
|
||||
if (CData::IsCData(valObj)) {
|
||||
sourceData = valObj;
|
||||
sourceType = CData::GetCType(sourceData);
|
||||
@ -3612,7 +3612,7 @@ CType::GetProtoFromType(JSContext* cx, JSObject* objArg, CTypeProtoSlot slot)
|
||||
// Get the requested ctypes.{Pointer,Array,Struct,Function}Type.prototype.
|
||||
jsval result = JS_GetReservedSlot(proto, slot);
|
||||
JS_ASSERT(!JSVAL_IS_PRIMITIVE(result));
|
||||
return JSVAL_TO_OBJECT(result);
|
||||
return result.toObjectOrNull();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -4639,7 +4639,7 @@ ExtractStructField(JSContext* cx, jsval val, JSObject** typeObj)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RootedObject obj(cx, JSVAL_TO_OBJECT(val));
|
||||
RootedObject obj(cx, val.toObjectOrNull());
|
||||
RootedObject iter(cx, JS_NewPropertyIterator(cx, obj));
|
||||
if (!iter)
|
||||
return nullptr;
|
||||
@ -5003,7 +5003,7 @@ StructType::Define(JSContext* cx, unsigned argc, jsval* vp)
|
||||
JS_ReportError(cx, "argument must be an array");
|
||||
return false;
|
||||
}
|
||||
RootedObject arr(cx, JSVAL_TO_OBJECT(arg));
|
||||
RootedObject arr(cx, arg.toObjectOrNull());
|
||||
if (!JS_IsArrayObject(cx, arr)) {
|
||||
JS_ReportError(cx, "argument must be an array");
|
||||
return false;
|
||||
@ -5314,7 +5314,7 @@ GetABI(JSContext* cx, jsval abiType, ffi_abi* result)
|
||||
if (JSVAL_IS_PRIMITIVE(abiType))
|
||||
return false;
|
||||
|
||||
ABICode abi = GetABICode(JSVAL_TO_OBJECT(abiType));
|
||||
ABICode abi = GetABICode(abiType.toObjectOrNull());
|
||||
|
||||
// determine the ABI from the subset of those available on the
|
||||
// given platform. ABI_DEFAULT specifies the default
|
||||
@ -5343,13 +5343,12 @@ GetABI(JSContext* cx, jsval abiType, ffi_abi* result)
|
||||
static JSObject*
|
||||
PrepareType(JSContext* cx, jsval type)
|
||||
{
|
||||
if (JSVAL_IS_PRIMITIVE(type) ||
|
||||
!CType::IsCType(JSVAL_TO_OBJECT(type))) {
|
||||
if (JSVAL_IS_PRIMITIVE(type) || !CType::IsCType(type.toObjectOrNull())) {
|
||||
JS_ReportError(cx, "not a ctypes type");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSObject* result = JSVAL_TO_OBJECT(type);
|
||||
JSObject* result = type.toObjectOrNull();
|
||||
TypeCode typeCode = CType::GetTypeCode(result);
|
||||
|
||||
if (typeCode == TYPE_array) {
|
||||
@ -5380,13 +5379,12 @@ PrepareType(JSContext* cx, jsval type)
|
||||
static JSObject*
|
||||
PrepareReturnType(JSContext* cx, jsval type)
|
||||
{
|
||||
if (JSVAL_IS_PRIMITIVE(type) ||
|
||||
!CType::IsCType(JSVAL_TO_OBJECT(type))) {
|
||||
if (JSVAL_IS_PRIMITIVE(type) || !CType::IsCType(type.toObjectOrNull())) {
|
||||
JS_ReportError(cx, "not a ctypes type");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSObject* result = JSVAL_TO_OBJECT(type);
|
||||
JSObject* result = type.toObjectOrNull();
|
||||
TypeCode typeCode = CType::GetTypeCode(result);
|
||||
|
||||
// Arrays and functions can never be return types.
|
||||
@ -5524,7 +5522,7 @@ NewFunctionInfo(JSContext* cx,
|
||||
JS_ReportError(cx, "Invalid ABI specification");
|
||||
return nullptr;
|
||||
}
|
||||
fninfo->mABI = JSVAL_TO_OBJECT(abiType);
|
||||
fninfo->mABI = abiType.toObjectOrNull();
|
||||
|
||||
// prepare the result type
|
||||
fninfo->mReturnType = PrepareReturnType(cx, returnType);
|
||||
@ -6297,7 +6295,7 @@ CData::Create(JSContext* cx,
|
||||
jsval slot = JS_GetReservedSlot(typeObj, SLOT_PROTO);
|
||||
JS_ASSERT(!JSVAL_IS_PRIMITIVE(slot));
|
||||
|
||||
RootedObject proto(cx, JSVAL_TO_OBJECT(slot));
|
||||
RootedObject proto(cx, slot.toObjectOrNull());
|
||||
RootedObject parent(cx, JS_GetParent(typeObj));
|
||||
JS_ASSERT(parent);
|
||||
|
||||
@ -6375,7 +6373,7 @@ CData::GetCType(JSObject* dataObj)
|
||||
JS_ASSERT(CData::IsCData(dataObj));
|
||||
|
||||
jsval slot = JS_GetReservedSlot(dataObj, SLOT_CTYPE);
|
||||
JSObject* typeObj = JSVAL_TO_OBJECT(slot);
|
||||
JSObject* typeObj = slot.toObjectOrNull();
|
||||
JS_ASSERT(CType::IsCType(typeObj));
|
||||
return typeObj;
|
||||
}
|
||||
@ -6746,7 +6744,7 @@ CDataFinalizer::Methods::ToSource(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedObject typeObj(cx, JSVAL_TO_OBJECT(valCodePtrType));
|
||||
RootedObject typeObj(cx, valCodePtrType.toObjectOrNull());
|
||||
JSString *srcDispose = CData::GetSourceString(cx, typeObj, &(p->code));
|
||||
if (!srcDispose) {
|
||||
return false;
|
||||
@ -6817,7 +6815,7 @@ CDataFinalizer::GetCType(JSContext *cx, JSObject *obj)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return JSVAL_TO_OBJECT(valData);
|
||||
return valData.toObjectOrNull();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
@ -6839,7 +6837,7 @@ CDataFinalizer::GetCData(JSContext *cx, JSObject *obj)
|
||||
JS_ReportError(cx, "Empty CDataFinalizer");
|
||||
return nullptr;
|
||||
}
|
||||
return JSVAL_TO_OBJECT(val);
|
||||
return val.toObjectOrNull();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -7408,7 +7406,7 @@ Int64::Construct(JSContext* cx,
|
||||
RootedValue slot(cx);
|
||||
RootedObject callee(cx, &args.callee());
|
||||
ASSERT_OK(JS_GetProperty(cx, callee, "prototype", &slot));
|
||||
RootedObject proto(cx, JSVAL_TO_OBJECT(slot));
|
||||
RootedObject proto(cx, slot.toObjectOrNull());
|
||||
JS_ASSERT(JS_GetClass(proto) == &sInt64ProtoClass);
|
||||
|
||||
JSObject* result = Int64Base::Construct(cx, proto, i, false);
|
||||
|
@ -53,7 +53,7 @@ BEGIN_TEST(testAddPropertyHook)
|
||||
obj = JS_NewObject(cx, &AddPropertyClass, JS::NullPtr(), JS::NullPtr());
|
||||
CHECK(obj);
|
||||
JS::RootedValue vobj(cx, OBJECT_TO_JSVAL(obj));
|
||||
JS::RootedObject arrObj(cx, JSVAL_TO_OBJECT(arr));
|
||||
JS::RootedObject arrObj(cx, arr.toObjectOrNull());
|
||||
CHECK(JS_DefineElement(cx, arrObj, i, vobj,
|
||||
JS_PropertyStub, JS_StrictPropertyStub,
|
||||
JSPROP_ENUMERATE));
|
||||
|
@ -83,7 +83,7 @@ ExhaustiveTest(const char funcode[])
|
||||
EVAL(funcode, &v);
|
||||
|
||||
EVAL(CALL_CODES[ArgCount], &v);
|
||||
Rooted<ArgumentsObject*> argsobj(cx, &JSVAL_TO_OBJECT(v)->as<ArgumentsObject>());
|
||||
Rooted<ArgumentsObject*> argsobj(cx, &v.toObjectOrNull()->as<ArgumentsObject>());
|
||||
|
||||
JS::AutoValueArray<MAX_ELEMS> elems(cx);
|
||||
|
||||
|
@ -14,8 +14,8 @@ BEGIN_TEST(test_BindCallable)
|
||||
EVAL("(function() { return this.somename; })", &func);
|
||||
CHECK(func.isObject());
|
||||
|
||||
JS::RootedObject funcObj(cx, JSVAL_TO_OBJECT(func));
|
||||
JS::RootedObject vObj(cx, JSVAL_TO_OBJECT(v));
|
||||
JS::RootedObject funcObj(cx, func.toObjectOrNull());
|
||||
JS::RootedObject vObj(cx, v.toObjectOrNull());
|
||||
JSObject* newCallable = JS_BindCallable(cx, funcObj, vObj);
|
||||
CHECK(newCallable);
|
||||
|
||||
|
@ -15,7 +15,7 @@ BEGIN_TEST(testConservativeGC)
|
||||
EVAL("({foo: 'bar'});", &v2);
|
||||
CHECK(v2.isObject());
|
||||
char objCopy[sizeof(JSObject)];
|
||||
js_memcpy(&objCopy, JSVAL_TO_OBJECT(v2), sizeof(JSObject));
|
||||
js_memcpy(&objCopy, v2.toObjectOrNull(), sizeof(JSObject));
|
||||
|
||||
JS::RootedValue v3(cx);
|
||||
EVAL("String(Math.PI);", &v3);
|
||||
@ -26,7 +26,7 @@ BEGIN_TEST(testConservativeGC)
|
||||
JS::RootedValue tmp(cx);
|
||||
EVAL("({foo2: 'bar2'});", &tmp);
|
||||
CHECK(tmp.isObject());
|
||||
JS::RootedObject obj2(cx, JSVAL_TO_OBJECT(tmp));
|
||||
JS::RootedObject obj2(cx, tmp.toObjectOrNull());
|
||||
char obj2Copy[sizeof(JSObject)];
|
||||
js_memcpy(&obj2Copy, obj2, sizeof(JSObject));
|
||||
|
||||
@ -47,7 +47,7 @@ BEGIN_TEST(testConservativeGC)
|
||||
|
||||
JS_GC(rt);
|
||||
|
||||
checkObjectFields((JSObject *)objCopy, JSVAL_TO_OBJECT(v2));
|
||||
checkObjectFields((JSObject *)objCopy, v2.toObjectOrNull());
|
||||
CHECK(!memcmp(strCopy, v3.toString(), sizeof(strCopy)));
|
||||
|
||||
checkObjectFields((JSObject *)obj2Copy, obj2);
|
||||
|
@ -11,7 +11,7 @@ BEGIN_TEST(testDeepFreeze_bug535703)
|
||||
{
|
||||
JS::RootedValue v(cx);
|
||||
EVAL("var x = {}; x;", &v);
|
||||
JS::RootedObject obj(cx, JSVAL_TO_OBJECT(v));
|
||||
JS::RootedObject obj(cx, v.toObjectOrNull());
|
||||
CHECK(JS_DeepFreezeObject(cx, obj)); // don't crash
|
||||
EVAL("Object.isFrozen(x)", &v);
|
||||
CHECK_SAME(v, JSVAL_TRUE);
|
||||
@ -28,7 +28,7 @@ BEGIN_TEST(testDeepFreeze_deep)
|
||||
EVAL("a", &a);
|
||||
EVAL("o", &o);
|
||||
|
||||
JS::RootedObject aobj(cx, JSVAL_TO_OBJECT(a));
|
||||
JS::RootedObject aobj(cx, a.toObjectOrNull());
|
||||
CHECK(JS_DeepFreezeObject(cx, aobj));
|
||||
|
||||
JS::RootedValue b(cx);
|
||||
@ -47,7 +47,7 @@ BEGIN_TEST(testDeepFreeze_loop)
|
||||
EVAL("x", &x);
|
||||
EVAL("y", &y);
|
||||
|
||||
JS::RootedObject xobj(cx, JSVAL_TO_OBJECT(x));
|
||||
JS::RootedObject xobj(cx, x.toObjectOrNull());
|
||||
CHECK(JS_DeepFreezeObject(cx, xobj));
|
||||
|
||||
JS::RootedValue b(cx);
|
||||
|
@ -32,7 +32,7 @@ BEGIN_TEST(testDefineGetterSetterNonEnumerable)
|
||||
JS::RootedObject funSetObj(cx, JS_GetFunctionObject(funSet));
|
||||
JS::RootedValue vset(cx, OBJECT_TO_JSVAL(funSetObj));
|
||||
|
||||
JS::RootedObject vObject(cx, JSVAL_TO_OBJECT(vobj));
|
||||
JS::RootedObject vObject(cx, vobj.toObjectOrNull());
|
||||
CHECK(JS_DefineProperty(cx, vObject, PROPERTY_NAME,
|
||||
JS::UndefinedHandleValue,
|
||||
JSPROP_GETTER | JSPROP_SETTER | JSPROP_ENUMERATE,
|
||||
|
@ -15,7 +15,7 @@ BEGIN_TEST(testDefineProperty_bug564344)
|
||||
"x.p(); // brand x's scope\n"
|
||||
"x;", &x);
|
||||
|
||||
JS::RootedObject obj(cx, JSVAL_TO_OBJECT(x));
|
||||
JS::RootedObject obj(cx, x.toObjectOrNull());
|
||||
for (int i = 0; i < 2; i++)
|
||||
CHECK(JS_DefineProperty(cx, obj, "q", JS::UndefinedHandleValue, JSPROP_SHARED));
|
||||
return true;
|
||||
|
@ -12,7 +12,7 @@ BEGIN_TEST(testFunctionProperties)
|
||||
JS::RootedValue x(cx);
|
||||
EVAL("(function f() {})", &x);
|
||||
|
||||
JS::RootedObject obj(cx, JSVAL_TO_OBJECT(x));
|
||||
JS::RootedObject obj(cx, x.toObjectOrNull());
|
||||
|
||||
JS::RootedValue y(cx);
|
||||
CHECK(JS_GetProperty(cx, obj, "arguments", &y));
|
||||
|
@ -23,7 +23,7 @@ BEGIN_TEST(testLookup_bug522590)
|
||||
|
||||
// Now make x.f a method.
|
||||
EVAL("mkobj()", &x);
|
||||
JS::RootedObject xobj(cx, JSVAL_TO_OBJECT(x));
|
||||
JS::RootedObject xobj(cx, x.toObjectOrNull());
|
||||
|
||||
// This lookup must not return an internal function object.
|
||||
JS::RootedValue r(cx);
|
||||
|
@ -128,7 +128,7 @@ bool TestCloneObject()
|
||||
CHECK(cloned_buffer.write(cx, v1, callbacks, nullptr));
|
||||
JS::RootedValue v2(cx);
|
||||
CHECK(cloned_buffer.read(cx, &v2, callbacks, nullptr));
|
||||
JS::RootedObject obj2(cx, JSVAL_TO_OBJECT(v2));
|
||||
JS::RootedObject obj2(cx, v2.toObjectOrNull());
|
||||
CHECK(VerifyObject(obj2, 8, 12, false));
|
||||
|
||||
return true;
|
||||
@ -164,7 +164,7 @@ bool TestTransferObject()
|
||||
CHECK(cloned_buffer.write(cx, v1, transferable, callbacks, nullptr));
|
||||
JS::RootedValue v2(cx);
|
||||
CHECK(cloned_buffer.read(cx, &v2, callbacks, nullptr));
|
||||
JS::RootedObject obj2(cx, JSVAL_TO_OBJECT(v2));
|
||||
JS::RootedObject obj2(cx, v2.toObjectOrNull());
|
||||
CHECK(VerifyObject(obj2, 8, 12, true));
|
||||
CHECK(isNeutered(obj1));
|
||||
|
||||
|
@ -60,7 +60,7 @@ BEGIN_TEST(testNewObject_1)
|
||||
|
||||
JS::RootedValue v(cx);
|
||||
EVAL("Array", &v);
|
||||
JS::RootedObject Array(cx, JSVAL_TO_OBJECT(v));
|
||||
JS::RootedObject Array(cx, v.toObjectOrNull());
|
||||
|
||||
// With no arguments.
|
||||
JS::RootedObject obj(cx, JS_New(cx, Array, JS::HandleValueArray::empty()));
|
||||
|
@ -104,14 +104,14 @@ BEGIN_TEST(testParseJSON_success)
|
||||
|
||||
CHECK(Parse(cx, "[]", &v));
|
||||
CHECK(!JSVAL_IS_PRIMITIVE(v));
|
||||
obj = JSVAL_TO_OBJECT(v);
|
||||
obj = v.toObjectOrNull();
|
||||
CHECK(JS_IsArrayObject(cx, obj));
|
||||
CHECK(JS_GetProperty(cx, obj, "length", &v2));
|
||||
CHECK_SAME(v2, JSVAL_ZERO);
|
||||
|
||||
CHECK(Parse(cx, "[1]", &v));
|
||||
CHECK(!JSVAL_IS_PRIMITIVE(v));
|
||||
obj = JSVAL_TO_OBJECT(v);
|
||||
obj = v.toObjectOrNull();
|
||||
CHECK(JS_IsArrayObject(cx, obj));
|
||||
CHECK(JS_GetProperty(cx, obj, "0", &v2));
|
||||
CHECK_SAME(v2, JSVAL_ONE);
|
||||
@ -122,12 +122,12 @@ BEGIN_TEST(testParseJSON_success)
|
||||
// Objects
|
||||
CHECK(Parse(cx, "{}", &v));
|
||||
CHECK(!JSVAL_IS_PRIMITIVE(v));
|
||||
obj = JSVAL_TO_OBJECT(v);
|
||||
obj = v.toObjectOrNull();
|
||||
CHECK(!JS_IsArrayObject(cx, obj));
|
||||
|
||||
CHECK(Parse(cx, "{ \"f\": 17 }", &v));
|
||||
CHECK(!JSVAL_IS_PRIMITIVE(v));
|
||||
obj = JSVAL_TO_OBJECT(v);
|
||||
obj = v.toObjectOrNull();
|
||||
CHECK(!JS_IsArrayObject(cx, obj));
|
||||
CHECK(JS_GetProperty(cx, obj, "f", &v2));
|
||||
CHECK_SAME(v2, INT_TO_JSVAL(17));
|
||||
|
@ -9,11 +9,11 @@ BEGIN_TEST(testObjectIsRegExp)
|
||||
JS::RootedValue val(cx);
|
||||
|
||||
EVAL("new Object", &val);
|
||||
JS::RootedObject obj(cx, JSVAL_TO_OBJECT(val));
|
||||
JS::RootedObject obj(cx, val.toObjectOrNull());
|
||||
CHECK(!JS_ObjectIsRegExp(cx, obj));
|
||||
|
||||
EVAL("/foopy/", &val);
|
||||
obj = JSVAL_TO_OBJECT(val);
|
||||
obj = val.toObjectOrNull();
|
||||
CHECK(JS_ObjectIsRegExp(cx, obj));
|
||||
|
||||
return true;
|
||||
@ -26,15 +26,15 @@ BEGIN_TEST(testGetRegExpFlags)
|
||||
JS::RootedObject obj(cx);
|
||||
|
||||
EVAL("/foopy/", &val);
|
||||
obj = JSVAL_TO_OBJECT(val);
|
||||
obj = val.toObjectOrNull();
|
||||
CHECK_EQUAL(JS_GetRegExpFlags(cx, obj), 0);
|
||||
|
||||
EVAL("/foopy/g", &val);
|
||||
obj = JSVAL_TO_OBJECT(val);
|
||||
obj = val.toObjectOrNull();
|
||||
CHECK_EQUAL(JS_GetRegExpFlags(cx, obj), JSREG_GLOB);
|
||||
|
||||
EVAL("/foopy/gi", &val);
|
||||
obj = JSVAL_TO_OBJECT(val);
|
||||
obj = val.toObjectOrNull();
|
||||
CHECK_EQUAL(JS_GetRegExpFlags(cx, obj), (JSREG_FOLD | JSREG_GLOB));
|
||||
|
||||
return true;
|
||||
@ -47,7 +47,7 @@ BEGIN_TEST(testGetRegExpSource)
|
||||
JS::RootedObject obj(cx);
|
||||
|
||||
EVAL("/foopy/", &val);
|
||||
obj = JSVAL_TO_OBJECT(val);
|
||||
obj = val.toObjectOrNull();
|
||||
JSString *source = JS_GetRegExpSource(cx, obj);
|
||||
CHECK(JS_FlatStringEqualsAscii(JS_ASSERT_STRING_IS_FLAT(source), "foopy"));
|
||||
|
||||
|
@ -16,7 +16,7 @@ BEGIN_TEST(testRegExpInstanceProperties)
|
||||
jsval regexpProtoVal;
|
||||
EVAL("RegExp.prototype", ®expProtoVal);
|
||||
|
||||
JSObject *regexpProto = JSVAL_TO_OBJECT(regexpProtoVal);
|
||||
JSObject *regexpProto = regexpProtoVal.toObjectOrNull();
|
||||
|
||||
if (!helper(regexpProto))
|
||||
return false;
|
||||
@ -27,7 +27,7 @@ BEGIN_TEST(testRegExpInstanceProperties)
|
||||
|
||||
jsval regexp;
|
||||
EVAL("/foopy/", ®exp);
|
||||
JSObject *robj = JSVAL_TO_OBJECT(regexp);
|
||||
JSObject *robj = regexp.toObjectOrNull();
|
||||
|
||||
CHECK(robj->lastProperty());
|
||||
CHECK_EQUAL(robj->compartment()->initialRegExpShape, robj->lastProperty());
|
||||
|
@ -758,7 +758,7 @@ js_ReportUncaughtException(JSContext *cx)
|
||||
if (JSVAL_IS_PRIMITIVE(exn)) {
|
||||
exnObject = nullptr;
|
||||
} else {
|
||||
exnObject = JSVAL_TO_OBJECT(exn);
|
||||
exnObject = exn.toObjectOrNull();
|
||||
}
|
||||
|
||||
JS_ClearPendingException(cx);
|
||||
|
@ -823,7 +823,7 @@ ToDisassemblySource(JSContext *cx, HandleValue v, JSAutoByteString *bytes)
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
JSObject *obj = JSVAL_TO_OBJECT(v);
|
||||
JSObject *obj = v.toObjectOrNull();
|
||||
if (obj->is<StaticBlockObject>()) {
|
||||
Rooted<StaticBlockObject*> block(cx, &obj->as<StaticBlockObject>());
|
||||
char *source = JS_sprintf_append(nullptr, "depth %d {", block->localOffset());
|
||||
|
@ -267,7 +267,7 @@ ExtractPerfMeasurement(jsval wrapper)
|
||||
|
||||
// This is what JS_GetInstancePrivate does internally. We can't
|
||||
// call JS_anything from here, because we don't have a JSContext.
|
||||
JSObject *obj = JSVAL_TO_OBJECT(wrapper);
|
||||
JSObject *obj = wrapper.toObjectOrNull();
|
||||
if (obj->getClass() != js::Valueify(&pm_class))
|
||||
return 0;
|
||||
|
||||
|
@ -3071,7 +3071,7 @@ static bool
|
||||
resolver_enumerate(JSContext *cx, HandleObject obj)
|
||||
{
|
||||
jsval v = JS_GetReservedSlot(obj, 0);
|
||||
RootedObject referent(cx, JSVAL_TO_OBJECT(v));
|
||||
RootedObject referent(cx, v.toObjectOrNull());
|
||||
|
||||
AutoIdArray ida(cx, JS_Enumerate(cx, referent));
|
||||
bool ok = !!ida;
|
||||
@ -4201,7 +4201,7 @@ Wrap(JSContext *cx, unsigned argc, jsval *vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedObject obj(cx, JSVAL_TO_OBJECT(v));
|
||||
RootedObject obj(cx, v.toObjectOrNull());
|
||||
JSObject *wrapped = Wrapper::New(cx, obj, &obj->global(),
|
||||
&Wrapper::singleton);
|
||||
if (!wrapped)
|
||||
@ -4983,7 +4983,7 @@ Help(JSContext *cx, unsigned argc, jsval *vp)
|
||||
JS_ReportError(cx, "primitive arg");
|
||||
return false;
|
||||
}
|
||||
obj = JSVAL_TO_OBJECT(v);
|
||||
obj = v.toObjectOrNull();
|
||||
if (!PrintHelp(cx, obj))
|
||||
return false;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 457065;
|
||||
var summary = 'Do not assert: !fp->callee || fp->thisp == JSVAL_TO_OBJECT(fp->argv[-1])';
|
||||
var summary = 'Do not assert: !fp->callee || fp->thisp == fp->argv[-1].toObjectOrNull()';
|
||||
var actual = '';
|
||||
var expect = '';
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 457065;
|
||||
var summary = 'Do not assert: !fp->callee || fp->thisp == JSVAL_TO_OBJECT(fp->argv[-1])';
|
||||
var summary = 'Do not assert: !fp->callee || fp->thisp == fp->argv[-1].toObjectOrNull()';
|
||||
var actual = '';
|
||||
var expect = '';
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 457065;
|
||||
var summary = 'Do not assert: !fp->callee || fp->thisp == JSVAL_TO_OBJECT(fp->argv[-1])';
|
||||
var summary = 'Do not assert: !fp->callee || fp->thisp == fp->argv[-1].toObjectOrNull()';
|
||||
var actual = '';
|
||||
var expect = '';
|
||||
|
||||
|
@ -45,7 +45,7 @@ function test()
|
||||
// =====
|
||||
(function(){ eval("for (x in ['', {}, '', {}]) { this; }" )})();
|
||||
|
||||
// Assertion failure: fp->thisp == JSVAL_TO_OBJECT(fp->argv[-1]), at ../jstracer.cpp:4172
|
||||
// Assertion failure: fp->thisp == fp->argv[-1].toObjectOrNull(), at ../jstracer.cpp:4172
|
||||
// =====
|
||||
for each (let x in ['', '', '']) { (new function(){} )}
|
||||
|
||||
|
@ -2469,7 +2469,7 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
|
||||
return ThrowAndFail(NS_ERROR_XPC_BAD_CID, cx, _retval);
|
||||
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wn;
|
||||
if (NS_FAILED(xpc->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(val),
|
||||
if (NS_FAILED(xpc->GetWrappedNativeOfJSObject(cx, val.toObjectOrNull(),
|
||||
getter_AddRefs(wn))) || !wn ||
|
||||
!(cClassID = do_QueryWrappedNative(wn))) {
|
||||
return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
|
||||
|
@ -1124,7 +1124,7 @@ XPCConvert::JSValToXPCException(MutableHandleValue s,
|
||||
|
||||
if (!JSVAL_IS_PRIMITIVE(s)) {
|
||||
// we have a JSObject
|
||||
RootedObject obj(cx, JSVAL_TO_OBJECT(s));
|
||||
RootedObject obj(cx, s.toObjectOrNull());
|
||||
|
||||
if (!obj) {
|
||||
NS_ERROR("when is an object not an object?");
|
||||
|
@ -645,7 +645,7 @@ GetIIDArg(uint32_t argc, const JS::Value& val, JSContext* cx)
|
||||
if (argc) {
|
||||
JSObject* iidobj;
|
||||
if (JSVAL_IS_PRIMITIVE(val) ||
|
||||
!(iidobj = JSVAL_TO_OBJECT(val)) ||
|
||||
!(iidobj = val.toObjectOrNull()) ||
|
||||
!(iid = xpc_JSObjectToID(cx, iidobj))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ PropertyOpForwarder(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
JS::RootedValue v(cx, js::GetFunctionNativeReserved(callee, 0));
|
||||
|
||||
JSObject *ptrobj = JSVAL_TO_OBJECT(v);
|
||||
JSObject *ptrobj = v.toObjectOrNull();
|
||||
Op *popp = static_cast<Op *>(JS_GetPrivate(ptrobj));
|
||||
|
||||
v = js::GetFunctionNativeReserved(callee, 1);
|
||||
|
@ -87,7 +87,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(XPCVariant)
|
||||
JS::Value val = tmp->GetJSValPreserveColor();
|
||||
if (val.isObjectOrNull()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mJSVal");
|
||||
cb.NoteJSChild(JSVAL_TO_OBJECT(val));
|
||||
cb.NoteJSChild(val.toObjectOrNull());
|
||||
}
|
||||
|
||||
nsVariant::Traverse(tmp->mData, cb);
|
||||
|
@ -1084,7 +1084,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
|
||||
if (!ok) {
|
||||
goto pre_call_clean_up;
|
||||
}
|
||||
thisObj = JSVAL_TO_OBJECT(v);
|
||||
thisObj = v.toObjectOrNull();
|
||||
if (!JS_WrapObject(cx, &thisObj))
|
||||
goto pre_call_clean_up;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ GetDoubleWrappedJSObject(XPCCallContext& ccx, XPCWrappedNative* wrapper)
|
||||
RootedValue val(ccx);
|
||||
if (JS_GetPropertyById(ccx, mainObj, id, &val) &&
|
||||
!JSVAL_IS_PRIMITIVE(val)) {
|
||||
obj = JSVAL_TO_OBJECT(val);
|
||||
obj = val.toObjectOrNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -381,7 +381,7 @@ DefinePropertyIfFound(XPCCallContext& ccx,
|
||||
MOZ_ASSERT(member->IsAttribute(), "way broken!");
|
||||
|
||||
propFlags |= JSPROP_GETTER | JSPROP_SHARED;
|
||||
JSObject* funobj = JSVAL_TO_OBJECT(funval);
|
||||
JSObject* funobj = funval.toObjectOrNull();
|
||||
JSPropertyOp getter = JS_DATA_TO_FUNC_PTR(JSPropertyOp, funobj);
|
||||
JSStrictPropertyOp setter;
|
||||
if (member->IsWritableAttribute()) {
|
||||
|
@ -835,7 +835,7 @@ nsXPConnect::CreateSandbox(JSContext *cx, nsIPrincipal *principal,
|
||||
"Bad return value from xpc_CreateSandboxObject()!");
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !JSVAL_IS_PRIMITIVE(rval)) {
|
||||
*_retval = XPCJSObjectHolder::newHolder(JSVAL_TO_OBJECT(rval));
|
||||
*_retval = XPCJSObjectHolder::newHolder(rval.toObjectOrNull());
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
|
@ -563,7 +563,7 @@ def writeArgumentUnboxing(f, i, name, type, optional, rvdeclared,
|
||||
f.write(" if (NS_FAILED(rv)) {\n")
|
||||
if isSetter:
|
||||
assert(propIndex is not None)
|
||||
f.write(" xpc_qsThrowBadSetterValue(cx, rv, JSVAL_TO_OBJECT(vp[1]), (uint16_t)%s);\n" %
|
||||
f.write(" xpc_qsThrowBadSetterValue(cx, rv, vp[1].toObjectOrNull(), (uint16_t)%s);\n" %
|
||||
propIndex)
|
||||
else:
|
||||
f.write(" xpc_qsThrowBadArg(cx, rv, vp, %d);\n" % i)
|
||||
@ -986,7 +986,7 @@ def writeQuickStub(f, customMethodCalls, stringtable, member, stubName,
|
||||
"cx, rv, vp);\n")
|
||||
else:
|
||||
f.write(" return xpc_qsThrowGetterSetterFailed(cx, rv, " +
|
||||
"JSVAL_TO_OBJECT(vp[1]), (uint16_t)%d);\n" %
|
||||
"vp[1].toObjectOrNull(), (uint16_t)%d);\n" %
|
||||
stringtable.stringIndex(member.name))
|
||||
|
||||
# Convert the return value.
|
||||
|
@ -96,7 +96,7 @@ InitAndSealCTypesClass(JSContext* cx, JS::Handle<JSObject*> global)
|
||||
if (!JS_GetProperty(cx, global, "ctypes", &ctypes))
|
||||
return false;
|
||||
|
||||
JS_SetCTypesCallbacks(JSVAL_TO_OBJECT(ctypes), &sCallbacks);
|
||||
JS_SetCTypesCallbacks(ctypes.toObjectOrNull(), &sCallbacks);
|
||||
|
||||
// Seal up Object, Function, Array and Error and their prototypes. (This
|
||||
// single object instance is shared amongst everyone who imports the ctypes
|
||||
|
@ -271,7 +271,7 @@ GetJSValueAsURI(JSContext* aCtx,
|
||||
nsCOMPtr<nsIXPConnect> xpc = mozilla::services::GetXPConnect();
|
||||
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrappedObj;
|
||||
nsresult rv = xpc->GetWrappedNativeOfJSObject(aCtx, JSVAL_TO_OBJECT(aValue),
|
||||
nsresult rv = xpc->GetWrappedNativeOfJSObject(aCtx, aValue.toObjectOrNull(),
|
||||
getter_AddRefs(wrappedObj));
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
nsCOMPtr<nsIURI> uri = do_QueryWrappedNative(wrappedObj);
|
||||
@ -2811,7 +2811,7 @@ History::UpdatePlaces(JS::Handle<JS::Value> aPlaceInfos,
|
||||
bool rc = JS_GetProperty(aCtx, info, "visits", &visitsVal);
|
||||
NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
|
||||
if (!JSVAL_IS_PRIMITIVE(visitsVal)) {
|
||||
visits = JSVAL_TO_OBJECT(visitsVal);
|
||||
visits = visitsVal.toObjectOrNull();
|
||||
NS_ENSURE_ARG(JS_IsArrayObject(aCtx, visits));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user