From 3a1f617fbf1b4fb35ff351639c81a8002f5fc784 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 27 Sep 2023 14:48:29 +0200 Subject: [PATCH] LibJS: Use Function as callback type in define_native_function/accessor There is not need to use SafeFunction because define_native_function or define_native_accessor will pass callback forward to NativeFunction that uses HeapFunction to visit it. --- Userland/Libraries/LibJS/Runtime/Object.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/Object.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index a61f042783..86efbcb4fd 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -1197,7 +1197,7 @@ void Object::set_prototype(Object* new_prototype) m_shape = shape.create_prototype_transition(new_prototype); } -void Object::define_native_accessor(Realm& realm, PropertyKey const& property_key, SafeFunction(VM&)> getter, SafeFunction(VM&)> setter, PropertyAttributes attribute) +void Object::define_native_accessor(Realm& realm, PropertyKey const& property_key, Function(VM&)> getter, Function(VM&)> setter, PropertyAttributes attribute) { FunctionObject* getter_function = nullptr; if (getter) @@ -1257,7 +1257,7 @@ Value Object::get_without_side_effects(PropertyKey const& property_key) const return {}; } -void Object::define_native_function(Realm& realm, PropertyKey const& property_key, SafeFunction(VM&)> native_function, i32 length, PropertyAttributes attribute) +void Object::define_native_function(Realm& realm, PropertyKey const& property_key, Function(VM&)> native_function, i32 length, PropertyAttributes attribute) { auto function = NativeFunction::create(realm, move(native_function), length, property_key, &realm); define_direct_property(property_key, function, attribute); diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index b414c6b64a..11e6777665 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -166,8 +166,8 @@ public: using IntrinsicAccessor = Value (*)(Realm&); void define_intrinsic_accessor(PropertyKey const&, PropertyAttributes attributes, IntrinsicAccessor accessor); - void define_native_function(Realm&, PropertyKey const&, SafeFunction(VM&)>, i32 length, PropertyAttributes attributes); - void define_native_accessor(Realm&, PropertyKey const&, SafeFunction(VM&)> getter, SafeFunction(VM&)> setter, PropertyAttributes attributes); + void define_native_function(Realm&, PropertyKey const&, Function(VM&)>, i32 length, PropertyAttributes attributes); + void define_native_accessor(Realm&, PropertyKey const&, Function(VM&)> getter, Function(VM&)> setter, PropertyAttributes attributes); virtual bool is_dom_node() const { return false; } virtual bool is_function() const { return false; }