mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
LibJS: Port Value::to_object() to NonnullGCPtr
This commit is contained in:
parent
e79f5b6e85
commit
f345f72b55
29 changed files with 264 additions and 263 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
||||
* Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2020-2023, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -33,20 +33,20 @@ TESTJS_GLOBAL_FUNCTION(run_queued_promise_jobs, runQueuedPromiseJobs)
|
|||
|
||||
TESTJS_GLOBAL_FUNCTION(get_weak_set_size, getWeakSetSize)
|
||||
{
|
||||
auto* object = TRY(vm.argument(0).to_object(vm));
|
||||
if (!is<JS::WeakSet>(object))
|
||||
auto object = TRY(vm.argument(0).to_object(vm));
|
||||
if (!is<JS::WeakSet>(*object))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WeakSet");
|
||||
auto* weak_set = static_cast<JS::WeakSet*>(object);
|
||||
return JS::Value(weak_set->values().size());
|
||||
auto& weak_set = static_cast<JS::WeakSet&>(*object);
|
||||
return JS::Value(weak_set.values().size());
|
||||
}
|
||||
|
||||
TESTJS_GLOBAL_FUNCTION(get_weak_map_size, getWeakMapSize)
|
||||
{
|
||||
auto* object = TRY(vm.argument(0).to_object(vm));
|
||||
if (!is<JS::WeakMap>(object))
|
||||
auto object = TRY(vm.argument(0).to_object(vm));
|
||||
if (!is<JS::WeakMap>(*object))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WeakMap");
|
||||
auto* weak_map = static_cast<JS::WeakMap*>(object);
|
||||
return JS::Value(weak_map->values().size());
|
||||
auto& weak_map = static_cast<JS::WeakMap&>(*object);
|
||||
return JS::Value(weak_map.values().size());
|
||||
}
|
||||
|
||||
TESTJS_GLOBAL_FUNCTION(mark_as_garbage, markAsGarbage)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue