1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:37:34 +00:00

LibJS: Convert internal_define_own_property() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-09-29 17:54:25 +01:00
parent 0e69a6e487
commit 5da210125e
16 changed files with 67 additions and 74 deletions

View file

@ -1417,7 +1417,7 @@ public:
generator.append(R"~~~(
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyName const&) const override;
virtual bool internal_set(JS::PropertyName const&, JS::Value, JS::Value) override;
virtual bool internal_define_own_property(JS::PropertyName const&, JS::PropertyDescriptor const&) override;
virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyName const&, JS::PropertyDescriptor const&) override;
virtual bool internal_delete(JS::PropertyName const&) override;
virtual JS::ThrowCompletionOr<bool> internal_prevent_extensions() override;
virtual JS::MarkedValueList internal_own_property_keys() const override;
@ -2051,7 +2051,7 @@ bool @class_name@::internal_set(JS::PropertyName const& property_name, JS::Value
// 3.9.3. [[DefineOwnProperty]], https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty
scoped_generator.append(R"~~~(
bool @class_name@::internal_define_own_property(JS::PropertyName const& property_name, JS::PropertyDescriptor const& property_descriptor)
JS::ThrowCompletionOr<bool> @class_name@::internal_define_own_property(JS::PropertyName const& property_name, JS::PropertyDescriptor const& property_descriptor)
{
[[maybe_unused]] auto& vm = this->vm();
auto& global_object = this->global_object();
@ -2076,8 +2076,8 @@ bool @class_name@::internal_define_own_property(JS::PropertyName const& property
scoped_generator.append(R"~~~(
// 3. Invoke the indexed property setter on O with P and Desc.[[Value]].
invoke_indexed_property_setter(global_object, impl(), property_name, *property_descriptor.value);
if (vm.exception())
return {};
if (auto* exception = vm.exception())
return JS::throw_completion(exception->value());
// 4. Return true.
return true;
@ -2110,7 +2110,7 @@ bool @class_name@::internal_define_own_property(JS::PropertyName const& property
if (!interface.extended_attributes.contains("LegacyOverrideBuiltIns")) {
scoped_generator.append(R"~~~(
// NOTE: This has to be done manually instead of using Object::has_own_property, as that would use the overrided internal_get_own_property.
auto own_property_named_p = TRY_OR_DISCARD(Object::internal_get_own_property(property_name));
auto own_property_named_p = TRY(Object::internal_get_own_property(property_name));
if (!own_property_named_p.has_value()))~~~");
}
@ -2135,8 +2135,8 @@ bool @class_name@::internal_define_own_property(JS::PropertyName const& property
// 2. Invoke the named property setter on O with P and Desc.[[Value]].
invoke_named_property_setter(global_object, impl(), property_name_as_string, *property_descriptor.value);
if (vm.exception())
return {};
if (auto* exception = vm.exception())
return JS::throw_completion(exception->value());
// 3. Return true.
return true;