Issue #2259 - Add mozilla::Result<V, E> and JS::Result<> for fallible return values

Based-on: m-c 1283562, 1277368/1, 1324828
This commit is contained in:
Martok 2023-06-17 16:05:46 +02:00 committed by roytam1
commit 4c2e378613
20 changed files with 905 additions and 73 deletions

View file

@ -258,9 +258,8 @@ NativeObject::createWithTemplate(JSContext* cx, gc::InitialHeap heap,
MOZ_ASSERT(CanBeFinalizedInBackground(kind, shape->getObjectClass()));
kind = gc::GetBackgroundAllocKind(kind);
JSObject* baseObj = create(cx, kind, heap, shape, group);
if (!baseObj)
return nullptr;
JSObject* baseObj;
JS_TRY_VAR_OR_RETURN_NULL(cx, baseObj, create(cx, kind, heap, shape, group));
return &baseObj->as<NativeObject>();
}
@ -272,9 +271,9 @@ NativeObject::copy(ExclusiveContext* cx, gc::AllocKind kind, gc::InitialHeap hea
RootedObjectGroup group(cx, templateObject->group());
MOZ_ASSERT(!templateObject->denseElementsAreCopyOnWrite());
JSObject* baseObj = create(cx, kind, heap, shape, group);
if (!baseObj)
return nullptr;
JSObject* baseObj;
JS_TRY_VAR_OR_RETURN_NULL(cx, baseObj, create(cx, kind, heap, shape, group));
NativeObject* obj = &baseObj->as<NativeObject>();
size_t span = shape->slotSpan();