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

LibJS: Remove old Native Functions

Now that all the usages were updated to the new ThrowCompletionOr based
version we can remove the legacy version.
This commit is contained in:
Idan Horowitz 2021-10-31 17:10:19 +02:00
parent 9d1fb85f93
commit 2eaed880b1
3 changed files with 0 additions and 44 deletions

View file

@ -1045,29 +1045,6 @@ void Object::set_prototype(Object* new_prototype)
m_shape = shape.create_prototype_transition(new_prototype);
}
void Object::define_old_native_accessor(PropertyKey const& property_name, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attribute)
{
Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> completion_getter = {};
if (getter) {
completion_getter = [getter = move(getter)](auto& vm, auto& global_object) -> ThrowCompletionOr<Value> {
auto result = getter(vm, global_object);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
return result;
};
}
Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> completion_setter = {};
if (setter) {
completion_setter = [setter = move(setter)](auto& vm, auto& global_object) -> ThrowCompletionOr<Value> {
auto result = setter(vm, global_object);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
return result;
};
}
define_native_accessor(property_name, move(completion_getter), move(completion_setter), attribute);
}
void Object::define_native_accessor(PropertyKey const& property_name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> getter, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> setter, PropertyAttributes attribute)
{
auto& vm = this->vm();
@ -1134,17 +1111,6 @@ Value Object::get_without_side_effects(const PropertyKey& property_name) const
return {};
}
void Object::define_old_native_function(PropertyKey const& property_name, Function<Value(VM&, GlobalObject&)> native_function, i32 length, PropertyAttributes attribute)
{
auto completion_native_function = [native_function = move(native_function), property_name](auto& vm, auto& global_object) -> ThrowCompletionOr<Value> {
auto result = native_function(vm, global_object);
if (auto* exception = vm.exception())
return throw_completion(exception->value());
return result;
};
define_native_function(property_name, move(completion_native_function), length, attribute);
}
void Object::define_native_function(PropertyKey const& property_name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> native_function, i32 length, PropertyAttributes attribute)
{
auto& vm = this->vm();