mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibJS: Convert Array::create{,_from}() to NonnullGCPtr
This commit is contained in:
parent
0c50751c13
commit
91b0123eaf
Notes:
sideshowbarker
2024-07-17 08:42:05 +09:00
Author: https://github.com/linusg
Commit: 91b0123eaf
Pull-request: https://github.com/SerenityOS/serenity/pull/16479
Reviewed-by: https://github.com/davidot ✅
25 changed files with 60 additions and 60 deletions
|
@ -17,7 +17,7 @@
|
|||
namespace JS {
|
||||
|
||||
// 10.4.2.2 ArrayCreate ( length [ , proto ] ), https://tc39.es/ecma262/#sec-arraycreate
|
||||
ThrowCompletionOr<Array*> Array::create(Realm& realm, u64 length, Object* prototype)
|
||||
ThrowCompletionOr<NonnullGCPtr<Array>> Array::create(Realm& realm, u64 length, Object* prototype)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
|
||||
|
@ -38,14 +38,14 @@ ThrowCompletionOr<Array*> Array::create(Realm& realm, u64 length, Object* protot
|
|||
MUST(array->internal_define_own_property(vm.names.length, { .value = Value(length), .writable = true, .enumerable = false, .configurable = false }));
|
||||
|
||||
// 7. Return A.
|
||||
return array;
|
||||
return NonnullGCPtr { *array };
|
||||
}
|
||||
|
||||
// 7.3.18 CreateArrayFromList ( elements ), https://tc39.es/ecma262/#sec-createarrayfromlist
|
||||
Array* Array::create_from(Realm& realm, Vector<Value> const& elements)
|
||||
NonnullGCPtr<Array> Array::create_from(Realm& realm, Vector<Value> const& elements)
|
||||
{
|
||||
// 1. Let array be ! ArrayCreate(0).
|
||||
auto* array = MUST(Array::create(realm, 0));
|
||||
auto array = MUST(Array::create(realm, 0));
|
||||
|
||||
// 2. Let n be 0.
|
||||
// 3. For each element e of elements, do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue