diff options
117 files changed, 216 insertions, 216 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 7ee5ea8ec5..1cfdae4a56 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -2004,7 +2004,7 @@ public: virtual ~@constructor_class@() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; - virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override; + virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } @@ -2135,7 +2135,7 @@ JS::ThrowCompletionOr<JS::Value> @constructor_class@::call() return vm().throw_completion<JS::TypeError>(JS::ErrorType::ConstructorWithoutNew, "@name@"); } -JS::ThrowCompletionOr<JS::Object*> @constructor_class@::construct(FunctionObject&) +JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::construct(FunctionObject&) { )~~~"); @@ -2172,7 +2172,7 @@ JS::ThrowCompletionOr<JS::Object*> @constructor_class@::construct(FunctionObject )~~~"); } generator.append(R"~~~( - return &(*impl); + return *impl; )~~~"); } else { // Multiple constructor overloads - can't do that yet. diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp index 431288c3e4..d70b0fa2db 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp @@ -38,7 +38,7 @@ ThrowCompletionOr<Value> AggregateErrorConstructor::call() } // 20.5.7.1.1 AggregateError ( errors, message [ , options ] ), https://tc39.es/ecma262/#sec-aggregate-error -ThrowCompletionOr<Object*> AggregateErrorConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> AggregateErrorConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& realm = *vm.current_realm(); @@ -69,7 +69,7 @@ ThrowCompletionOr<Object*> AggregateErrorConstructor::construct(FunctionObject& MUST(aggregate_error->define_property_or_throw(vm.names.errors, { .value = Array::create_from(realm, errors_list), .writable = true, .enumerable = false, .configurable = true })); // 7. Return O. - return aggregate_error.ptr(); + return aggregate_error; } } diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h index 7d3492d5b9..ee146040ab 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~AggregateErrorConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit AggregateErrorConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp index 4b7840c9ed..96e7b06e7c 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp @@ -44,7 +44,7 @@ ThrowCompletionOr<Value> ArrayBufferConstructor::call() } // 25.1.3.1 ArrayBuffer ( length ), https://tc39.es/ecma262/#sec-arraybuffer-length -ThrowCompletionOr<Object*> ArrayBufferConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> ArrayBufferConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto byte_length_or_error = vm.argument(0).to_index(vm); @@ -57,7 +57,7 @@ ThrowCompletionOr<Object*> ArrayBufferConstructor::construct(FunctionObject& new } return error; } - return TRY(allocate_array_buffer(vm, new_target, byte_length_or_error.release_value())); + return *TRY(allocate_array_buffer(vm, new_target, byte_length_or_error.release_value())); } // 25.1.4.1 ArrayBuffer.isView ( arg ), https://tc39.es/ecma262/#sec-arraybuffer.isview diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h index 4befd09841..60a4fb82a7 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h @@ -18,7 +18,7 @@ public: virtual ~ArrayBufferConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit ArrayBufferConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index 74fcdc0012..2ba248f61b 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -47,7 +47,7 @@ ThrowCompletionOr<Value> ArrayConstructor::call() } // 23.1.1.1 Array ( ...values ), https://tc39.es/ecma262/#sec-array -ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> ArrayConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& realm = *vm.current_realm(); @@ -55,7 +55,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe auto* proto = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::array_prototype)); if (vm.argument_count() == 0) - return MUST(Array::create(realm, 0, proto)).ptr(); + return MUST(Array::create(realm, 0, proto)); if (vm.argument_count() == 1) { auto length = vm.argument(0); @@ -70,7 +70,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "array"); } TRY(array->set(vm.names.length, Value(int_length), Object::ShouldThrowExceptions::Yes)); - return array.ptr(); + return array; } auto array = TRY(Array::create(realm, vm.argument_count(), proto)); @@ -78,7 +78,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe for (size_t k = 0; k < vm.argument_count(); ++k) MUST(array->create_data_property_or_throw(k, vm.argument(k))); - return array.ptr(); + return array; } // 23.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ), https://tc39.es/ecma262/#sec-array.from diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h index dd972edf50..ee88e9a08b 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h @@ -18,7 +18,7 @@ public: virtual ~ArrayConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit ArrayConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp index 3124818127..892fb7cff2 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp @@ -35,7 +35,7 @@ ThrowCompletionOr<Value> AsyncFunctionConstructor::call() } // 27.7.1.1 AsyncFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-async-function-constructor-arguments -ThrowCompletionOr<Object*> AsyncFunctionConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> AsyncFunctionConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -46,7 +46,7 @@ ThrowCompletionOr<Object*> AsyncFunctionConstructor::construct(FunctionObject& n auto& args = vm.running_execution_context().arguments; // 3. Return CreateDynamicFunction(C, NewTarget, async, args). - return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Async, args)); + return *TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Async, args)); } } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h index defef48dfd..cf11753202 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h @@ -18,7 +18,7 @@ public: virtual ~AsyncFunctionConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit AsyncFunctionConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp index f389a590af..c09341312f 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp @@ -36,7 +36,7 @@ ThrowCompletionOr<Value> AsyncGeneratorFunctionConstructor::call() } // 27.4.1.1 AsyncGeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-asyncgeneratorfunction -ThrowCompletionOr<Object*> AsyncGeneratorFunctionConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> AsyncGeneratorFunctionConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -47,7 +47,7 @@ ThrowCompletionOr<Object*> AsyncGeneratorFunctionConstructor::construct(Function auto& args = vm.running_execution_context().arguments; // 3. Return ? CreateDynamicFunction(C, NewTarget, asyncGenerator, args). - return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::AsyncGenerator, args)); + return *TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::AsyncGenerator, args)); } } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h index f3c474e36e..0b1a4e26d2 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h @@ -18,7 +18,7 @@ public: virtual ~AsyncGeneratorFunctionConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit AsyncGeneratorFunctionConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp index c8bf3c2ead..c0e193782b 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp @@ -56,7 +56,7 @@ ThrowCompletionOr<Value> BigIntConstructor::call() } // 21.2.1.1 BigInt ( value ), https://tc39.es/ecma262/#sec-bigint-constructor-number-value -ThrowCompletionOr<Object*> BigIntConstructor::construct(FunctionObject&) +ThrowCompletionOr<NonnullGCPtr<Object>> BigIntConstructor::construct(FunctionObject&) { return vm().throw_completion<TypeError>(ErrorType::NotAConstructor, "BigInt"); } diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h index a5448f5156..59335e3318 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h @@ -18,7 +18,7 @@ public: virtual ~BigIntConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit BigIntConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp index 3a6c78d406..98fb7dba17 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp @@ -37,12 +37,12 @@ ThrowCompletionOr<Value> BooleanConstructor::call() } // 20.3.1.1 Boolean ( value ), https://tc39.es/ecma262/#sec-boolean-constructor-boolean-value -ThrowCompletionOr<Object*> BooleanConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> BooleanConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto b = vm.argument(0).to_boolean(); - return TRY(ordinary_create_from_constructor<BooleanObject>(vm, new_target, &Intrinsics::boolean_prototype, b)).ptr(); + return TRY(ordinary_create_from_constructor<BooleanObject>(vm, new_target, &Intrinsics::boolean_prototype, b)); } } diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h index 71cd414339..3520b64a1d 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h @@ -18,7 +18,7 @@ public: virtual ~BooleanConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit BooleanConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp index 592628fb7c..d606ec02a5 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp @@ -38,7 +38,7 @@ ThrowCompletionOr<Value> DataViewConstructor::call() } // 25.3.2.1 DataView ( buffer [ , byteOffset [ , byteLength ] ] ), https://tc39.es/ecma262/#sec-dataview-buffer-byteoffset-bytelength -ThrowCompletionOr<Object*> DataViewConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> DataViewConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -72,7 +72,7 @@ ThrowCompletionOr<Object*> DataViewConstructor::construct(FunctionObject& new_ta if (array_buffer.is_detached()) return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); - return data_view.ptr(); + return data_view; } } diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h index e2b067a5b1..632c4e0e86 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h @@ -18,7 +18,7 @@ public: virtual ~DataViewConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override; private: explicit DataViewConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp index efe44785aa..607b0eb8b8 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -208,7 +208,7 @@ ThrowCompletionOr<Value> DateConstructor::call() } // 21.4.2.1 Date ( ...values ), https://tc39.es/ecma262/#sec-date -ThrowCompletionOr<Object*> DateConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> DateConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -299,7 +299,7 @@ ThrowCompletionOr<Object*> DateConstructor::construct(FunctionObject& new_target // 6. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Date.prototype%", « [[DateValue]] »). // 7. Set O.[[DateValue]] to dv. // 8. Return O. - return TRY(ordinary_create_from_constructor<Date>(vm, new_target, &Intrinsics::date_prototype, date_value)).ptr(); + return TRY(ordinary_create_from_constructor<Date>(vm, new_target, &Intrinsics::date_prototype, date_value)); } // 21.4.3.1 Date.now ( ), https://tc39.es/ecma262/#sec-date.now diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.h b/Userland/Libraries/LibJS/Runtime/DateConstructor.h index ba67fbabee..7e66408ffa 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.h @@ -18,7 +18,7 @@ public: virtual ~DateConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit DateConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp index 18e9440717..b2b10d1665 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp @@ -35,7 +35,7 @@ ThrowCompletionOr<Value> ErrorConstructor::call() } // 20.5.1.1 Error ( message [ , options ] ), https://tc39.es/ecma262/#sec-error-message -ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> ErrorConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -58,7 +58,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe TRY(error->install_error_cause(options)); // 5. Return O. - return error.ptr(); + return error; } #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ @@ -88,7 +88,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe } \ \ /* 20.5.6.1.1 NativeError ( message [ , options ] ), https://tc39.es/ecma262/#sec-nativeerror */ \ - ThrowCompletionOr<Object*> ConstructorName::construct(FunctionObject& new_target) \ + ThrowCompletionOr<NonnullGCPtr<Object>> ConstructorName::construct(FunctionObject& new_target) \ { \ auto& vm = this->vm(); \ \ @@ -111,7 +111,7 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe TRY(error->install_error_cause(options)); \ \ /* 5. Return O. */ \ - return error.ptr(); \ + return error; \ } JS_ENUMERATE_NATIVE_ERRORS diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h index 98d3bea32d..2bc6996308 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -19,7 +19,7 @@ public: virtual ~ErrorConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit ErrorConstructor(Realm&); @@ -27,23 +27,23 @@ private: virtual bool has_constructor() const override { return true; } }; -#define DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName) \ - class ConstructorName final : public NativeFunction { \ - JS_OBJECT(ConstructorName, NativeFunction); \ - \ - public: \ - virtual void initialize(Realm&) override; \ - virtual ~ConstructorName() override; \ - virtual ThrowCompletionOr<Value> call() override; \ - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; \ - \ - private: \ - explicit ConstructorName(Realm&); \ - \ - virtual bool has_constructor() const override \ - { \ - return true; \ - } \ +#define DECLARE_NATIVE_ERROR_CONSTRUCTOR(ClassName, snake_name, PrototypeName, ConstructorName) \ + class ConstructorName final : public NativeFunction { \ + JS_OBJECT(ConstructorName, NativeFunction); \ + \ + public: \ + virtual void initialize(Realm&) override; \ + virtual ~ConstructorName() override; \ + virtual ThrowCompletionOr<Value> call() override; \ + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; \ + \ + private: \ + explicit ConstructorName(Realm&); \ + \ + virtual bool has_constructor() const override \ + { \ + return true; \ + } \ }; #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp index 815c1aaa9b..186bbffad9 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp @@ -37,7 +37,7 @@ ThrowCompletionOr<Value> FinalizationRegistryConstructor::call() } // 26.2.1.1 FinalizationRegistry ( cleanupCallback ), https://tc39.es/ecma262/#sec-finalization-registry-cleanup-callback -ThrowCompletionOr<Object*> FinalizationRegistryConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> FinalizationRegistryConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -56,7 +56,7 @@ ThrowCompletionOr<Object*> FinalizationRegistryConstructor::construct(FunctionOb // 7. Set finalizationRegistry.[[Cells]] to a new empty List. // NOTE: This is done inside FinalizationRegistry instead of here. // 8. Return finalizationRegistry. - return TRY(ordinary_create_from_constructor<FinalizationRegistry>(vm, new_target, &Intrinsics::finalization_registry_prototype, *realm(), vm.host_make_job_callback(cleanup_callback.as_function()))).ptr(); + return TRY(ordinary_create_from_constructor<FinalizationRegistry>(vm, new_target, &Intrinsics::finalization_registry_prototype, *realm(), vm.host_make_job_callback(cleanup_callback.as_function()))); } } diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h index d857c7bd4d..a93a1c2315 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h @@ -18,7 +18,7 @@ public: virtual ~FinalizationRegistryConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override; private: explicit FinalizationRegistryConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp index a935c66065..1c3b6e6c2d 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp @@ -265,7 +265,7 @@ ThrowCompletionOr<Value> FunctionConstructor::call() } // 20.2.1.1 Function ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-function-p1-p2-pn-body -ThrowCompletionOr<Object*> FunctionConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> FunctionConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -276,7 +276,7 @@ ThrowCompletionOr<Object*> FunctionConstructor::construct(FunctionObject& new_ta auto& args = vm.running_execution_context().arguments; // 3. Return ? CreateDynamicFunction(C, NewTarget, normal, args). - return TRY(create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Normal, args)); + return *TRY(create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Normal, args)); } } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h index 0366034232..1cf6ad0613 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h @@ -21,7 +21,7 @@ public: virtual ~FunctionConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit FunctionConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp index 0faac0dbf2..8b9f04fac8 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp @@ -34,7 +34,7 @@ ThrowCompletionOr<Value> GeneratorFunctionConstructor::call() } // 27.3.1.1 GeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-generatorfunction -ThrowCompletionOr<Object*> GeneratorFunctionConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> GeneratorFunctionConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -45,7 +45,7 @@ ThrowCompletionOr<Object*> GeneratorFunctionConstructor::construct(FunctionObjec auto& args = vm.running_execution_context().arguments; // 3. Return ? CreateDynamicFunction(C, NewTarget, generator, args). - return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Generator, args)); + return *TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Generator, args)); } } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h index d4bc8eca2a..f73ef9e0d8 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h @@ -19,7 +19,7 @@ public: virtual ~GeneratorFunctionConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit GeneratorFunctionConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp index 413d5aeb25..46897f21f2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp @@ -157,7 +157,7 @@ ThrowCompletionOr<Value> CollatorConstructor::call() } // 10.1.1 Intl.Collator ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.collator -ThrowCompletionOr<Object*> CollatorConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> CollatorConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -174,7 +174,7 @@ ThrowCompletionOr<Object*> CollatorConstructor::construct(FunctionObject& new_ta auto collator = TRY(ordinary_create_from_constructor<Collator>(vm, new_target, &Intrinsics::intl_collator_prototype)); // 6. Return ? InitializeCollator(collator, locales, options). - return TRY(initialize_collator(vm, collator, locales, options)); + return *TRY(initialize_collator(vm, collator, locales, options)); } // 10.2.2 Intl.Collator.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.collator.supportedlocalesof diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h index 240122823e..19ade8f457 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h @@ -18,7 +18,7 @@ public: virtual ~CollatorConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit CollatorConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp index 9b66178776..9422e37f9c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp @@ -46,7 +46,7 @@ ThrowCompletionOr<Value> DateTimeFormatConstructor::call() } // 11.1.1 Intl.DateTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.datetimeformat -ThrowCompletionOr<Object*> DateTimeFormatConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> DateTimeFormatConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -64,7 +64,7 @@ ThrowCompletionOr<Object*> DateTimeFormatConstructor::construct(FunctionObject& // b. Return ? ChainDateTimeFormat(dateTimeFormat, NewTarget, this). // 5. Return dateTimeFormat. - return date_time_format.ptr(); + return date_time_format; } // 11.2.2 Intl.DateTimeFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.datetimeformat.supportedlocalesof diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h index 1f0ea3f72e..33a144e4cb 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h @@ -18,7 +18,7 @@ public: virtual ~DateTimeFormatConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit DateTimeFormatConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp index 5d82004996..81a897fdc7 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp @@ -44,7 +44,7 @@ ThrowCompletionOr<Value> DisplayNamesConstructor::call() } // 12.1.1 Intl.DisplayNames ( locales, options ), https://tc39.es/ecma402/#sec-Intl.DisplayNames -ThrowCompletionOr<Object*> DisplayNamesConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> DisplayNamesConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -130,7 +130,7 @@ ThrowCompletionOr<Object*> DisplayNamesConstructor::construct(FunctionObject& ne // 29. Set displayNames.[[Fields]] to styleFields. // 30. Return displayNames. - return display_names.ptr(); + return display_names; } // 12.2.2 Intl.DisplayNames.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.supportedLocalesOf diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h index ccd289d11b..68827b3807 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h @@ -18,7 +18,7 @@ public: virtual ~DisplayNamesConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit DisplayNamesConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp index ba8af2a739..4abb840f8c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp @@ -42,7 +42,7 @@ ThrowCompletionOr<Value> DurationFormatConstructor::call() } // 1.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat -ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> DurationFormatConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -138,7 +138,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject& duration_format->set_fractional_digits(Optional<u8>(TRY(get_number_option(vm, *options, vm.names.fractionalDigits, 0, 9, 0)))); // 19. Return durationFormat. - return duration_format.ptr(); + return duration_format; } // 1.3.2 Intl.DurationFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.supportedLocalesOf diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h index f0b37af706..81e7f99801 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h @@ -18,7 +18,7 @@ public: virtual ~DurationFormatConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit DurationFormatConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp index f0f30cce9d..e272feceed 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp @@ -43,7 +43,7 @@ ThrowCompletionOr<Value> ListFormatConstructor::call() } // 13.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat -ThrowCompletionOr<Object*> ListFormatConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> ListFormatConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -91,7 +91,7 @@ ThrowCompletionOr<Object*> ListFormatConstructor::construct(FunctionObject& new_ // Note: The remaining steps are skipped in favor of deferring to LibUnicode. // 19. Return listFormat. - return list_format.ptr(); + return list_format; } // 13.2.2 Intl.ListFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat.supportedLocalesOf diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h index 3f4827ece2..466b623908 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h @@ -18,7 +18,7 @@ public: virtual ~ListFormatConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit ListFormatConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp index 625d031b54..957a35a4da 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp @@ -241,7 +241,7 @@ ThrowCompletionOr<Value> LocaleConstructor::call() } // 14.1.1 Intl.Locale ( tag [ , options ] ), https://tc39.es/ecma402/#sec-Intl.Locale -ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> LocaleConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -362,7 +362,7 @@ ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_targ locale->set_numbering_system(result.nu.release_value()); // 37. Return locale. - return locale.ptr(); + return locale; } } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h index d4524696cc..645f966805 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h @@ -18,7 +18,7 @@ public: virtual ~LocaleConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit LocaleConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp index ab0d89c8fe..6a9dc66e13 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp @@ -42,7 +42,7 @@ ThrowCompletionOr<Value> NumberFormatConstructor::call() } // 15.1.1 Intl.NumberFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.numberformat -ThrowCompletionOr<Object*> NumberFormatConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> NumberFormatConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -60,7 +60,7 @@ ThrowCompletionOr<Object*> NumberFormatConstructor::construct(FunctionObject& ne // b. Return ? ChainNumberFormat(numberFormat, NewTarget, this). // 5. Return numberFormat. - return number_format.ptr(); + return number_format; } // 15.2.2 Intl.NumberFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.numberformat.supportedlocalesof diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h index ebe3bd603f..92014e80cf 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h @@ -19,7 +19,7 @@ public: virtual ~NumberFormatConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit NumberFormatConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp index ef424edd4b..3748e0918e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp @@ -43,7 +43,7 @@ ThrowCompletionOr<Value> PluralRulesConstructor::call() } // 16.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules -ThrowCompletionOr<Object*> PluralRulesConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> PluralRulesConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -54,7 +54,7 @@ ThrowCompletionOr<Object*> PluralRulesConstructor::construct(FunctionObject& new auto plural_rules = TRY(ordinary_create_from_constructor<PluralRules>(vm, new_target, &Intrinsics::intl_plural_rules_prototype)); // 3. Return ? InitializePluralRules(pluralRules, locales, options). - return TRY(initialize_plural_rules(vm, plural_rules, locales, options)); + return *TRY(initialize_plural_rules(vm, plural_rules, locales, options)); } // 16.2.2 Intl.PluralRules.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.pluralrules.supportedlocalesof diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h index 5b7b7f73f9..256f38d73d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h @@ -18,7 +18,7 @@ public: virtual ~PluralRulesConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit PluralRulesConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp index d1b70729ef..60b5525c96 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp @@ -46,7 +46,7 @@ ThrowCompletionOr<Value> RelativeTimeFormatConstructor::call() } // 17.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat -ThrowCompletionOr<Object*> RelativeTimeFormatConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> RelativeTimeFormatConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -57,7 +57,7 @@ ThrowCompletionOr<Object*> RelativeTimeFormatConstructor::construct(FunctionObje auto relative_time_format = TRY(ordinary_create_from_constructor<RelativeTimeFormat>(vm, new_target, &Intrinsics::intl_relative_time_format_prototype)); // 3. Return ? InitializeRelativeTimeFormat(relativeTimeFormat, locales, options). - return TRY(initialize_relative_time_format(vm, relative_time_format, locales, options)); + return *TRY(initialize_relative_time_format(vm, relative_time_format, locales, options)); } // 17.2.2 Intl.RelativeTimeFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.supportedLocalesOf diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h index 0fd742fb41..9459dc1fde 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h @@ -18,7 +18,7 @@ public: virtual ~RelativeTimeFormatConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit RelativeTimeFormatConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp index 956d6e1307..827e9f6b79 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp @@ -42,7 +42,7 @@ ThrowCompletionOr<Value> SegmenterConstructor::call() } // 18.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter -ThrowCompletionOr<Object*> SegmenterConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> SegmenterConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -83,7 +83,7 @@ ThrowCompletionOr<Object*> SegmenterConstructor::construct(FunctionObject& new_t segmenter->set_segmenter_granularity(granularity.as_string().deprecated_string()); // 14. Return segmenter. - return segmenter.ptr(); + return segmenter; } // 18.2.2 Intl.Segmenter.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.segmenter.supportedlocalesof diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h index a9f90e8dbb..6cd08b38c9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h @@ -18,7 +18,7 @@ public: virtual ~SegmenterConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit SegmenterConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp index f295a4c7c3..c71aaab39d 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp @@ -39,14 +39,14 @@ ThrowCompletionOr<Value> MapConstructor::call() } // 24.1.1.1 Map ( [ iterable ] ), https://tc39.es/ecma262/#sec-map-iterable -ThrowCompletionOr<Object*> MapConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> MapConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto map = TRY(ordinary_create_from_constructor<Map>(vm, new_target, &Intrinsics::map_prototype)); if (vm.argument(0).is_nullish()) - return map.ptr(); + return map; auto adder = TRY(map->get(vm.names.set)); if (!adder.is_function()) @@ -63,7 +63,7 @@ ThrowCompletionOr<Object*> MapConstructor::construct(FunctionObject& new_target) return {}; })); - return map.ptr(); + return map; } // 24.1.2.2 get Map [ @@species ], https://tc39.es/ecma262/#sec-get-map-@@species diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.h b/Userland/Libraries/LibJS/Runtime/MapConstructor.h index ed4d6c8ffc..1338d0eabb 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.h @@ -18,7 +18,7 @@ public: virtual ~MapConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override; private: explicit MapConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index e0107c0d07..21c31d92a4 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -227,7 +227,7 @@ ThrowCompletionOr<Value> NativeFunction::call() return m_native_function(vm()); } -ThrowCompletionOr<Object*> NativeFunction::construct(FunctionObject&) +ThrowCompletionOr<NonnullGCPtr<Object>> NativeFunction::construct(FunctionObject&) { // Needs to be overridden if [[Construct]] is needed. VERIFY_NOT_REACHED(); diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.h b/Userland/Libraries/LibJS/Runtime/NativeFunction.h index f8f0b48d2c..62d9c41d75 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.h @@ -32,7 +32,7 @@ public: // Used for [[Call]] / [[Construct]]'s "...result of evaluating F in a manner that conforms to the specification of F". // Needs to be overridden by all NativeFunctions without an m_native_function. virtual ThrowCompletionOr<Value> call(); - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target); + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target); virtual FlyString const& name() const override { return m_name; }; virtual bool is_strict_mode() const override; diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp index 71361f7eb3..6b0d1054cd 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp @@ -90,7 +90,7 @@ ThrowCompletionOr<Value> NumberConstructor::call() } // 21.1.1.1 Number ( value ), https://tc39.es/ecma262/#sec-number-constructor-number-value -ThrowCompletionOr<Object*> NumberConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> NumberConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); // NOTE: get_value_from_constructor_argument performs steps 1 and 2 and returns n. @@ -99,7 +99,7 @@ ThrowCompletionOr<Object*> NumberConstructor::construct(FunctionObject& new_targ // 4. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Number.prototype%", « [[NumberData]] »). // 5. Set O.[[NumberData]] to n. // 6. Return O. - return TRY(ordinary_create_from_constructor<NumberObject>(vm, new_target, &Intrinsics::number_prototype, number.as_double())).ptr(); + return TRY(ordinary_create_from_constructor<NumberObject>(vm, new_target, &Intrinsics::number_prototype, number.as_double())); } // 21.1.2.2 Number.isFinite ( number ), https://tc39.es/ecma262/#sec-number.isfinite diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.h b/Userland/Libraries/LibJS/Runtime/NumberConstructor.h index e523bafcbe..45d32f1e21 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.h @@ -18,7 +18,7 @@ public: virtual ~NumberConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit NumberConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index eeb8371f03..6c35411b28 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -64,17 +64,17 @@ ThrowCompletionOr<Value> ObjectConstructor::call() } // 20.1.1.1 Object ( [ value ] ), https://tc39.es/ecma262/#sec-object-value -ThrowCompletionOr<Object*> ObjectConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> ObjectConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& realm = *vm.current_realm(); if (&new_target != this) - return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype, ConstructWithPrototypeTag::Tag)).ptr(); + return TRY(ordinary_create_from_constructor<Object>(vm, new_target, &Intrinsics::object_prototype, ConstructWithPrototypeTag::Tag)); auto value = vm.argument(0); if (value.is_nullish()) - return Object::create(realm, realm.intrinsics().object_prototype()).ptr(); - return value.to_object(vm); + return Object::create(realm, realm.intrinsics().object_prototype()); + return *TRY(value.to_object(vm)); } enum class GetOwnPropertyKeysType { diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h index 58b731fc7f..c7900468a8 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> - * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -19,7 +19,7 @@ public: virtual ~ObjectConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit ObjectConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index 4d58319afb..8fa851e473 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -275,7 +275,7 @@ ThrowCompletionOr<Value> PromiseConstructor::call() } // 27.2.3.1 Promise ( executor ), https://tc39.es/ecma262/#sec-promise-executor -ThrowCompletionOr<Object*> PromiseConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> PromiseConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -305,7 +305,7 @@ ThrowCompletionOr<Object*> PromiseConstructor::construct(FunctionObject& new_tar } // 11. Return promise. - return promise.ptr(); + return promise; } // 27.2.4.1 Promise.all ( iterable ), https://tc39.es/ecma262/#sec-promise.all diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h index 3780ed9b1e..917c317ed7 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~PromiseConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit PromiseConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp index e7dcd95d7c..db37f85008 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -47,10 +47,10 @@ ThrowCompletionOr<Value> ProxyConstructor::call() } // 28.2.1.1 Proxy ( target, handler ), https://tc39.es/ecma262/#sec-proxy-target-handler -ThrowCompletionOr<Object*> ProxyConstructor::construct(FunctionObject&) +ThrowCompletionOr<NonnullGCPtr<Object>> ProxyConstructor::construct(FunctionObject&) { auto& vm = this->vm(); - return TRY(proxy_create(vm, vm.argument(0), vm.argument(1))); + return *TRY(proxy_create(vm, vm.argument(0), vm.argument(1))); } // 28.2.2.1 Proxy.revocable ( target, handler ), https://tc39.es/ecma262/#sec-proxy.revocable diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h index 8cdb0cd677..46414bee0f 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org> - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -19,7 +19,7 @@ public: virtual ~ProxyConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit ProxyConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp index 492305da8e..0059177abe 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp @@ -80,7 +80,7 @@ ThrowCompletionOr<Value> RegExpConstructor::call() } // 22.2.3.1 RegExp ( pattern, flags ), https://tc39.es/ecma262/#sec-regexp-pattern-flags -ThrowCompletionOr<Object*> RegExpConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> RegExpConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -137,7 +137,7 @@ ThrowCompletionOr<Object*> RegExpConstructor::construct(FunctionObject& new_targ auto regexp_object = TRY(regexp_alloc(vm, new_target)); // 8. Return ? RegExpInitialize(O, P, F). - return TRY(regexp_object->regexp_initialize(vm, pattern_value, flags_value)).ptr(); + return TRY(regexp_object->regexp_initialize(vm, pattern_value, flags_value)); } // 22.2.4.2 get RegExp [ @@species ], https://tc39.es/ecma262/#sec-get-regexp-@@species diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h index 11e14a5a2f..a754513739 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h @@ -19,7 +19,7 @@ public: virtual ~RegExpConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; RegExpLegacyStaticProperties& legacy_static_properties() { return m_legacy_static_properties; } diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp index a9b45f10a6..3534769a87 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp @@ -39,14 +39,14 @@ ThrowCompletionOr<Value> SetConstructor::call() } // 24.2.1.1 Set ( [ iterable ] ), https://tc39.es/ecma262/#sec-set-iterable -ThrowCompletionOr<Object*> SetConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> SetConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto set = TRY(ordinary_create_from_constructor<Set>(vm, new_target, &Intrinsics::set_prototype)); if (vm.argument(0).is_nullish()) - return set.ptr(); + return set; auto adder = TRY(set->get(vm.names.add)); if (!adder.is_function()) @@ -57,7 +57,7 @@ ThrowCompletionOr<Object*> SetConstructor::construct(FunctionObject& new_target) return {}; })); - return set.ptr(); + return set; } // 24.2.2.2 get Set [ @@species ], https://tc39.es/ecma262/#sec-get-set-@@species diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.h b/Userland/Libraries/LibJS/Runtime/SetConstructor.h index e84f4c447e..b11a2cf90d 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.h @@ -18,7 +18,7 @@ public: virtual ~SetConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override; private: explicit SetConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp index ef14ed8574..6252e83ce7 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp @@ -37,7 +37,7 @@ ThrowCompletionOr<Value> ShadowRealmConstructor::call() } // 3.2.1 ShadowRealm ( ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm -ThrowCompletionOr<Object*> ShadowRealmConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> ShadowRealmConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -71,7 +71,7 @@ ThrowCompletionOr<Object*> ShadowRealmConstructor::construct(FunctionObject& new global_object.initialize(object->shadow_realm()); // 13. Return O. - return object.ptr(); + return object; } } diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h index a5c8dd5a1f..16fae21238 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~ShadowRealmConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit ShadowRealmConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 6a31626521..9fd6b22f3c 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -50,7 +50,7 @@ ThrowCompletionOr<Value> StringConstructor::call() } // 22.1.1.1 String ( value ), https://tc39.es/ecma262/#sec-string-constructor-string-value -ThrowCompletionOr<Object*> StringConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> StringConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto& realm = *vm.current_realm(); @@ -61,7 +61,7 @@ ThrowCompletionOr<Object*> StringConstructor::construct(FunctionObject& new_targ else primitive_string = TRY(vm.argument(0).to_primitive_string(vm)); auto* prototype = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::string_prototype)); - return StringObject::create(realm, *primitive_string, *prototype).ptr(); + return StringObject::create(realm, *primitive_string, *prototype); } // 22.1.2.4 String.raw ( template, ...substitutions ), https://tc39.es/ecma262/#sec-string.raw diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.h b/Userland/Libraries/LibJS/Runtime/StringConstructor.h index ea00356da9..f05574d541 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.h @@ -18,7 +18,7 @@ public: virtual ~StringConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit StringConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp index e255300764..cca758dac3 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp @@ -46,7 +46,7 @@ ThrowCompletionOr<Value> SymbolConstructor::call() } // 20.4.1.1 Symbol ( [ description ] ), https://tc39.es/ecma262/#sec-symbol-description -ThrowCompletionOr<Object*> SymbolConstructor::construct(FunctionObject&) +ThrowCompletionOr<NonnullGCPtr<Object>> SymbolConstructor::construct(FunctionObject&) { return vm().throw_completion<TypeError>(ErrorType::NotAConstructor, "Symbol"); } diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h index 93b6bbf625..01fee91c62 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h @@ -18,7 +18,7 @@ public: virtual ~SymbolConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit SymbolConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp index 16e73cbc1c..61ccc8ce31 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp @@ -42,7 +42,7 @@ ThrowCompletionOr<Value> CalendarConstructor::call() } // 12.2.1 Temporal.Calendar ( id ), https://tc39.es/proposal-temporal/#sec-temporal.calendar -ThrowCompletionOr<Object*> CalendarConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> CalendarConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -56,7 +56,7 @@ ThrowCompletionOr<Object*> CalendarConstructor::construct(FunctionObject& new_ta } // 4. Return ? CreateTemporalCalendar(id, NewTarget). - return TRY(create_temporal_calendar(vm, identifier, &new_target)); + return *TRY(create_temporal_calendar(vm, identifier, &new_target)); } // 12.3.2 Temporal.Calendar.from ( calendarLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.from diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h index dfe868740f..67476a8238 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~CalendarConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit CalendarConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp index 6df7d303ef..bbf44649cf 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp @@ -46,7 +46,7 @@ ThrowCompletionOr<Value> DurationConstructor::call() } // 7.1.1 Temporal.Duration ( [ years [ , months [ , weeks [ , days [ , hours [ , minutes [ , seconds [ , milliseconds [ , microseconds [ , nanoseconds ] ] ] ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.duration -ThrowCompletionOr<Object*> DurationConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> DurationConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -81,7 +81,7 @@ ThrowCompletionOr<Object*> DurationConstructor::construct(FunctionObject& new_ta auto ns = TRY(to_integer_if_integral(vm, vm.argument(9), ErrorType::TemporalInvalidDuration)); // 12. Return ? CreateTemporalDuration(y, mo, w, d, h, m, s, ms, mis, ns, NewTarget). - return TRY(create_temporal_duration(vm, y, mo, w, d, h, m, s, ms, mis, ns, &new_target)); + return *TRY(create_temporal_duration(vm, y, mo, w, d, h, m, s, ms, mis, ns, &new_target)); } // 7.2.2 Temporal.Duration.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.duration.from diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h index d83d07026a..ffe4d78245 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~DurationConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit DurationConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp index ab97a62de1..4993f0be61 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp @@ -49,7 +49,7 @@ ThrowCompletionOr<Value> InstantConstructor::call() } // 8.1.1 Temporal.Instant ( epochNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant -ThrowCompletionOr<Object*> InstantConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> InstantConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -61,7 +61,7 @@ ThrowCompletionOr<Object*> InstantConstructor::construct(FunctionObject& new_tar return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 4. Return ? CreateTemporalInstant(epochNanoseconds, NewTarget). - return TRY(create_temporal_instant(vm, *epoch_nanoseconds, &new_target)); + return *TRY(create_temporal_instant(vm, *epoch_nanoseconds, &new_target)); } // 8.2.2 Temporal.Instant.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.instant.from diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h index d56e143290..f6a1844040 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~InstantConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit InstantConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp index b458489258..64515508f6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp @@ -46,7 +46,7 @@ ThrowCompletionOr<Value> PlainDateConstructor::call() } // 3.1.1 Temporal.PlainDate ( isoYear, isoMonth, isoDay [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate -ThrowCompletionOr<Object*> PlainDateConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> PlainDateConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -69,7 +69,7 @@ ThrowCompletionOr<Object*> PlainDateConstructor::construct(FunctionObject& new_t return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDate); // 6. Return ? CreateTemporalDate(y, m, d, calendar, NewTarget). - return TRY(create_temporal_date(vm, y, m, d, *calendar, &new_target)); + return *TRY(create_temporal_date(vm, y, m, d, *calendar, &new_target)); } // 3.2.2 Temporal.PlainDate.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.from diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h index 57c9b09bd0..e6f13118a7 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h @@ -18,7 +18,7 @@ public: virtual ~PlainDateConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit PlainDateConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp index 202a36ead1..58eabd06a1 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp @@ -46,7 +46,7 @@ ThrowCompletionOr<Value> PlainDateTimeConstructor::call() } // 5.1.1 Temporal.PlainDateTime ( isoYear, isoMonth, isoDay [ , hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond [ , calendarLike ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime -ThrowCompletionOr<Object*> PlainDateTimeConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> PlainDateTimeConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -88,7 +88,7 @@ ThrowCompletionOr<Object*> PlainDateTimeConstructor::construct(FunctionObject& n return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDateTime); // 12. Return ? CreateTemporalDateTime(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar, NewTarget). - return TRY(create_temporal_date_time(vm, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, *calendar, &new_target)); + return *TRY(create_temporal_date_time(vm, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, *calendar, &new_target)); } // 5.2.2 Temporal.PlainDateTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.from diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h index cebd1843f9..d1f5bd67e5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~PlainDateTimeConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit PlainDateTimeConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp index faf2c1ad20..161d5eec9a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp @@ -44,7 +44,7 @@ ThrowCompletionOr<Value> PlainMonthDayConstructor::call() } // 10.1.1 Temporal.PlainMonthDay ( isoMonth, isoDay [ , calendarLike [ , referenceISOYear ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday -ThrowCompletionOr<Object*> PlainMonthDayConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> PlainMonthDayConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -78,7 +78,7 @@ ThrowCompletionOr<Object*> PlainMonthDayConstructor::construct(FunctionObject& n return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainMonthDay); // 7. Return ? CreateTemporalMonthDay(m, d, calendar, ref, NewTarget). - return TRY(create_temporal_month_day(vm, m, d, *calendar, ref, &new_target)); + return *TRY(create_temporal_month_day(vm, m, d, *calendar, ref, &new_target)); } // 10.2.2 Temporal.PlainMonthDay.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.from diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h index f3a31ea24d..136c7d1526 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~PlainMonthDayConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit PlainMonthDayConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp index c939dd637f..a99ae83b10 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp @@ -44,7 +44,7 @@ ThrowCompletionOr<Value> PlainTimeConstructor::call() } // 4.1.1 Temporal.PlainTime ( [ hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime -ThrowCompletionOr<Object*> PlainTimeConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> PlainTimeConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -74,7 +74,7 @@ ThrowCompletionOr<Object*> PlainTimeConstructor::construct(FunctionObject& new_t return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainTime); // 8. Return ? CreateTemporalTime(hour, minute, second, millisecond, microsecond, nanosecond, NewTarget). - return TRY(create_temporal_time(vm, hour, minute, second, millisecond, microsecond, nanosecond, &new_target)); + return *TRY(create_temporal_time(vm, hour, minute, second, millisecond, microsecond, nanosecond, &new_target)); } // 4.2.2 Temporal.PlainTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.from diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h index 4b1df4b3dd..0f03dec2db 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~PlainTimeConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit PlainTimeConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp index a73cfaeaa7..f89a7433c3 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp @@ -46,7 +46,7 @@ ThrowCompletionOr<Value> PlainYearMonthConstructor::call() } // 9.1.1 Temporal.PlainYearMonth ( isoYear, isoMonth [ , calendarLike [ , referenceISODay ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth -ThrowCompletionOr<Object*> PlainYearMonthConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> PlainYearMonthConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -80,7 +80,7 @@ ThrowCompletionOr<Object*> PlainYearMonthConstructor::construct(FunctionObject& return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainYearMonth); // 7. Return ? CreateTemporalYearMonth(y, m, calendar, ref, NewTarget). - return TRY(create_temporal_year_month(vm, y, m, *calendar, ref, &new_target)); + return *TRY(create_temporal_year_month(vm, y, m, *calendar, ref, &new_target)); } // 9.2.2 Temporal.PlainYearMonth.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.from diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h index 8068ec43ca..1f51297e27 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~PlainYearMonthConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit PlainYearMonthConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp index 0eaeb120cf..878dd7abf1 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp @@ -43,7 +43,7 @@ ThrowCompletionOr<Value> TimeZoneConstructor::call() } // 11.2.1 Temporal.TimeZone ( identifier ), https://tc39.es/proposal-temporal/#sec-temporal.timezone -ThrowCompletionOr<Object*> TimeZoneConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> TimeZoneConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -63,7 +63,7 @@ ThrowCompletionOr<Object*> TimeZoneConstructor::construct(FunctionObject& new_ta } // 4. Return ? CreateTemporalTimeZone(identifier, NewTarget). - return TRY(create_temporal_time_zone(vm, identifier, &new_target)); + return *TRY(create_temporal_time_zone(vm, identifier, &new_target)); } // 11.3.2 Temporal.TimeZone.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.from diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h index 65923cd488..5de3ea1e26 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~TimeZoneConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit TimeZoneConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp index e94cc32ec1..efd84a930a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp @@ -48,7 +48,7 @@ ThrowCompletionOr<Value> ZonedDateTimeConstructor::call() } // 6.1.1 Temporal.ZonedDateTime ( epochNanoseconds, timeZoneLike [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime -ThrowCompletionOr<Object*> ZonedDateTimeConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> ZonedDateTimeConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -66,7 +66,7 @@ ThrowCompletionOr<Object*> ZonedDateTimeConstructor::construct(FunctionObject& n auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, vm.argument(2))); // 6. Return ? CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar, NewTarget). - return TRY(create_temporal_zoned_date_time(vm, *epoch_nanoseconds, *time_zone, *calendar, &new_target)); + return *TRY(create_temporal_zoned_date_time(vm, *epoch_nanoseconds, *time_zone, *calendar, &new_target)); } // 6.2.2 Temporal.ZonedDateTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.from diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h index 459651e115..b1779d8206 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ public: virtual ~ZonedDateTimeConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; private: explicit ZonedDateTimeConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp index d5e327f31c..5cde063444 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp @@ -505,13 +505,13 @@ void TypedArrayBase::visit_edges(Visitor& visitor) } \ \ /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ - ThrowCompletionOr<Object*> ConstructorName::construct(FunctionObject& new_target) \ + ThrowCompletionOr<NonnullGCPtr<Object>> ConstructorName::construct(FunctionObject& new_target) \ { \ auto& vm = this->vm(); \ auto& realm = *vm.current_realm(); \ \ if (vm.argument_count() == 0) \ - return TRY(ClassName::create(realm, 0, new_target)).ptr(); \ + return TRY(ClassName::create(realm, 0, new_target)); \ \ auto first_argument = vm.argument(0); \ if (first_argument.is_object()) { \ @@ -532,7 +532,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor) TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \ } \ } \ - return typed_array.ptr(); \ + return typed_array; \ } \ \ auto array_length_or_error = first_argument.to_index(vm); \ @@ -550,7 +550,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor) /* FIXME: What is the best/correct behavior here? */ \ if (Checked<u32>::multiplication_would_overflow(array_length, sizeof(Type))) \ return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \ - return TRY(ClassName::create(realm, array_length, new_target)).ptr(); \ + return TRY(ClassName::create(realm, array_length, new_target)); \ } #undef __JS_ENUMERATE diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index e879f2e3b4..d4701df3ee 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -493,7 +493,7 @@ ThrowCompletionOr<double> compare_typed_array_elements(VM&, Value x, Value y, Fu virtual ~ConstructorName() override; \ \ virtual ThrowCompletionOr<Value> call() override; \ - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; \ + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; \ \ private: \ explicit ConstructorName(Realm&, Object& prototype); \ diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp index 80f3e417ef..4e0bf47376 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp @@ -45,7 +45,7 @@ ThrowCompletionOr<Value> TypedArrayConstructor::call() } // 23.2.1.1 %TypedArray% ( ), https://tc39.es/ecma262/#sec-%typedarray% -ThrowCompletionOr<Object*> TypedArrayConstructor::construct(FunctionObject&) +ThrowCompletionOr<NonnullGCPtr<Object>> TypedArrayConstructor::construct(FunctionObject&) { return vm().throw_completion<TypeError>(ErrorType::ClassIsAbstract, "TypedArray"); } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h index e98eeb4155..c4c66209e4 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h @@ -19,7 +19,7 @@ public: virtual ~TypedArrayConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; protected: TypedArrayConstructor(FlyString const& name, Object& prototype); diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp index 4c6007244b..031e3a7f2d 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp @@ -37,14 +37,14 @@ ThrowCompletionOr<Value> WeakMapConstructor::call() } // 24.3.1.1 WeakMap ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakmap-iterable -ThrowCompletionOr<Object*> WeakMapConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> WeakMapConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto weak_map = TRY(ordinary_create_from_constructor<WeakMap>(vm, new_target, &Intrinsics::weak_map_prototype)); if (vm.argument(0).is_nullish()) - return weak_map.ptr(); + return weak_map; auto adder = TRY(weak_map->get(vm.names.set)); if (!adder.is_function()) @@ -61,7 +61,7 @@ ThrowCompletionOr<Object*> WeakMapConstructor::construct(FunctionObject& new_tar return {}; })); - return weak_map.ptr(); + return weak_map; } } diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h index ff1ccaa11e..57810ad481 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h @@ -18,7 +18,7 @@ public: virtual ~WeakMapConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override; private: explicit WeakMapConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp index dc9b887baa..1379313c05 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp @@ -36,7 +36,7 @@ ThrowCompletionOr<Value> WeakRefConstructor::call() } // 26.1.1.1 WeakRef ( target ), https://tc39.es/ecma262/#sec-weak-ref-target -ThrowCompletionOr<Object*> WeakRefConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> WeakRefConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -45,9 +45,9 @@ ThrowCompletionOr<Object*> WeakRefConstructor::construct(FunctionObject& new_tar return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, target.to_string_without_side_effects()); if (target.is_object()) - return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_object())).ptr(); + return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_object())); VERIFY(target.is_symbol()); - return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_symbol())).ptr(); + return TRY(ordinary_create_from_constructor<WeakRef>(vm, new_target, &Intrinsics::weak_ref_prototype, target.as_symbol())); } } diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h index e25a5fb9ce..a3afbf755f 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h @@ -18,7 +18,7 @@ public: virtual ~WeakRefConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override; private: explicit WeakRefConstructor(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp index b3fda331e7..f48baadb11 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp @@ -37,14 +37,14 @@ ThrowCompletionOr<Value> WeakSetConstructor::call() } // 24.4.1.1 WeakSet ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakset-iterable -ThrowCompletionOr<Object*> WeakSetConstructor::construct(FunctionObject& new_target) +ThrowCompletionOr<NonnullGCPtr<Object>> WeakSetConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); auto weak_set = TRY(ordinary_create_from_constructor<WeakSet>(vm, new_target, &Intrinsics::weak_set_prototype)); if (vm.argument(0).is_nullish()) - return weak_set.ptr(); + return weak_set; auto adder = TRY(weak_set->get(vm.names.add)); if (!adder.is_function()) @@ -55,7 +55,7 @@ ThrowCompletionOr<Object*> WeakSetConstructor::construct(FunctionObject& new_tar return {}; })); - return weak_set.ptr(); + return weak_set; } } diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h index de9e1a3944..7e423630d0 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h @@ -18,7 +18,7 @@ public: virtual ~WeakSetConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; - virtual ThrowCompletionOr<Object*> construct(FunctionObject&) override; + virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject&) override; private: explicit WeakSetConstructor(Realm&); diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp index 8017818ae4..f3e9561345 100644 --- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp @@ -33,7 +33,7 @@ JS::ThrowCompletionOr<JS::Value> AudioConstructor::call() } // https://html.spec.whatwg.org/multipage/media.html#dom-audio -JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&) +JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> AudioConstructor::construct(FunctionObject&) { auto& vm = this->vm(); @@ -57,7 +57,7 @@ JS::ThrowCompletionOr<JS::Object*> AudioConstructor::construct(FunctionObject&) } // 5. Return audio. - return audio.ptr(); + return audio; } } diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h index 36a88b628b..85f464da7b 100644 --- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h @@ -18,7 +18,7 @@ public: virtual ~AudioConstructor() override = default; virtual JS::ThrowCompletionOr<JS::Value> call() override; - virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override; + virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp index 554f699089..2d1f968ef4 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp @@ -33,7 +33,7 @@ JS::ThrowCompletionOr<JS::Value> ImageConstructor::call() } // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-image -JS::ThrowCompletionOr<JS::Object*> ImageConstructor::construct(FunctionObject&) +JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> ImageConstructor::construct(FunctionObject&) { auto& vm = this->vm(); @@ -57,7 +57,7 @@ JS::ThrowCompletionOr<JS::Object*> ImageConstructor::construct(FunctionObject&) } // 5. Return img. - return image_element.ptr(); + return image_element; } } diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h index d16e61bbb9..a5b5f058d9 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h @@ -18,7 +18,7 @@ public: virtual ~ImageConstructor() override = default; virtual JS::ThrowCompletionOr<JS::Value> call() override; - virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override; + virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp index 8934e19777..9d1b84371f 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp @@ -22,7 +22,7 @@ JS::ThrowCompletionOr<JS::Value> LocationConstructor::call() return vm().throw_completion<JS::TypeError>(JS::ErrorType::ConstructorWithoutNew, "Location"); } -JS::ThrowCompletionOr<JS::Object*> LocationConstructor::construct(FunctionObject&) +JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> LocationConstructor::construct(FunctionObject&) { return vm().throw_completion<JS::TypeError>(JS::ErrorType::NotAConstructor, "Location"); } diff --git a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h index 41b5345a24..65be2f7415 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h @@ -19,7 +19,7 @@ public: virtual ~LocationConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; - virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override; + virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp index f015d326dd..8c75e0e055 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -35,7 +35,7 @@ JS::ThrowCompletionOr<JS::Value> OptionConstructor::call() } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-option -JS::ThrowCompletionOr<JS::Object*> OptionConstructor::construct(FunctionObject&) +JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> OptionConstructor::construct(FunctionObject&) { auto& vm = this->vm(); auto& realm = *vm.current_realm(); @@ -74,7 +74,7 @@ JS::ThrowCompletionOr<JS::Object*> OptionConstructor::construct(FunctionObject&) option_element->m_selected = vm.argument(3).to_boolean(); // 7. Return option. - return option_element.ptr(); + return option_element; } } diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h index 919762b970..a212ddb398 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h @@ -18,7 +18,7 @@ public: virtual ~OptionConstructor() override = default; virtual JS::ThrowCompletionOr<JS::Value> call() override; - virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override; + virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp index b83c62d828..d6f93ab501 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp @@ -22,7 +22,7 @@ JS::ThrowCompletionOr<JS::Value> WindowConstructor::call() return vm().throw_completion<JS::TypeError>(JS::ErrorType::ConstructorWithoutNew, "Window"); } -JS::ThrowCompletionOr<JS::Object*> WindowConstructor::construct(FunctionObject&) +JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WindowConstructor::construct(FunctionObject&) { return vm().throw_completion<JS::TypeError>(JS::ErrorType::NotAConstructor, "Window"); } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h index 3dda78c0d3..b287c8ffe3 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h @@ -19,7 +19,7 @@ public: virtual ~WindowConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; - virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override; + virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp index 026f633d7c..a2d71570d6 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp @@ -26,7 +26,7 @@ JS::ThrowCompletionOr<JS::Value> WebAssemblyInstanceConstructor::call() return vm().throw_completion<JS::TypeError>(JS::ErrorType::ConstructorWithoutNew, "WebAssembly.Instance"); } -JS::ThrowCompletionOr<JS::Object*> WebAssemblyInstanceConstructor::construct(FunctionObject&) +JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WebAssemblyInstanceConstructor::construct(FunctionObject&) { auto& vm = this->vm(); auto& realm = *vm.current_realm(); @@ -36,7 +36,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyInstanceConstructor::construct(Fun return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WebAssembly.Module"); auto& module_object = static_cast<WebAssemblyModuleObject&>(*module_argument); auto result = TRY(WebAssemblyObject::instantiate_module(vm, module_object.module())); - return heap().allocate<WebAssemblyInstanceObject>(realm, realm, result).ptr(); + return heap().allocate<WebAssemblyInstanceObject>(realm, realm, result); } void WebAssemblyInstanceConstructor::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h index 98bf578947..52c2849a9d 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h @@ -19,7 +19,7 @@ public: virtual ~WebAssemblyInstanceConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; - virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override; + virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp index 01beff4b04..bbb04cd1bf 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp @@ -23,7 +23,7 @@ JS::ThrowCompletionOr<JS::Value> WebAssemblyMemoryConstructor::call() return vm().throw_completion<JS::TypeError>(JS::ErrorType::ConstructorWithoutNew, "WebAssembly.Memory"); } -JS::ThrowCompletionOr<JS::Object*> WebAssemblyMemoryConstructor::construct(FunctionObject&) +JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WebAssemblyMemoryConstructor::construct(FunctionObject&) { auto& vm = this->vm(); auto& realm = *vm.current_realm(); @@ -46,7 +46,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyMemoryConstructor::construct(Funct if (!address.has_value()) return vm.throw_completion<JS::TypeError>("Wasm Memory allocation failed"); - return vm.heap().allocate<WebAssemblyMemoryObject>(realm, realm, *address).ptr(); + return vm.heap().allocate<WebAssemblyMemoryObject>(realm, realm, *address); } void WebAssemblyMemoryConstructor::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h index df983ac235..4fa79fd3cb 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h @@ -19,7 +19,7 @@ public: virtual ~WebAssemblyMemoryConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; - virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override; + virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp index 2ffba3ebf6..ab11610d3d 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp @@ -25,7 +25,7 @@ JS::ThrowCompletionOr<JS::Value> WebAssemblyModuleConstructor::call() return vm().throw_completion<JS::TypeError>(JS::ErrorType::ConstructorWithoutNew, "WebAssembly.Module"); } -JS::ThrowCompletionOr<JS::Object*> WebAssemblyModuleConstructor::construct(FunctionObject&) +JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WebAssemblyModuleConstructor::construct(FunctionObject&) { auto& vm = this->vm(); auto& realm = *vm.current_realm(); @@ -33,7 +33,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyModuleConstructor::construct(Funct auto* buffer_object = TRY(vm.argument(0).to_object(vm)); auto result = TRY(parse_module(vm, buffer_object)); - return heap().allocate<WebAssemblyModuleObject>(realm, realm, result).ptr(); + return heap().allocate<WebAssemblyModuleObject>(realm, realm, result); } void WebAssemblyModuleConstructor::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h index 911f3582a4..54a2a3d4b1 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h @@ -19,7 +19,7 @@ public: virtual ~WebAssemblyModuleConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; - virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override; + virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp index 2a0db96664..c63a16a877 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp @@ -26,7 +26,7 @@ JS::ThrowCompletionOr<JS::Value> WebAssemblyTableConstructor::call() return vm().throw_completion<JS::TypeError>(JS::ErrorType::ConstructorWithoutNew, "WebAssembly.Table"); } -JS::ThrowCompletionOr<JS::Object*> WebAssemblyTableConstructor::construct(FunctionObject&) +JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WebAssemblyTableConstructor::construct(FunctionObject&) { auto& vm = this->vm(); auto& realm = *vm.current_realm(); @@ -77,7 +77,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyTableConstructor::construct(Functi for (auto& element : table.elements()) element = reference; - return vm.heap().allocate<WebAssemblyTableObject>(realm, realm, *address).ptr(); + return vm.heap().allocate<WebAssemblyTableObject>(realm, realm, *address); } void WebAssemblyTableConstructor::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h index f8c0df3225..3896baee24 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h @@ -19,7 +19,7 @@ public: virtual ~WebAssemblyTableConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; - virtual JS::ThrowCompletionOr<JS::Object*> construct(JS::FunctionObject& new_target) override; + virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override; private: virtual bool has_constructor() const override { return true; } |