diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index a8ee8e7883..ddc0bed9b9 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -16,7 +16,7 @@ namespace JS { // 10.3.3 CreateBuiltinFunction ( behaviour, length, name, additionalInternalSlotsList [ , realm [ , prototype [ , prefix ] ] ] ), https://tc39.es/ecma262/#sec-createbuiltinfunction // NOTE: This doesn't consider additionalInternalSlotsList, which is rarely used, and can either be implemented using only the `function` lambda, or needs a NativeFunction subclass. -NativeFunction* NativeFunction::create(Realm& allocating_realm, Function(VM&)> behaviour, i32 length, PropertyKey const& name, Optional realm, Optional prototype, Optional const& prefix) +NativeFunction* NativeFunction::create(Realm& allocating_realm, SafeFunction(VM&)> behaviour, i32 length, PropertyKey const& name, Optional realm, Optional prototype, Optional const& prefix) { auto& vm = allocating_realm.vm(); @@ -51,12 +51,12 @@ NativeFunction* NativeFunction::create(Realm& allocating_realm, Function(VM&)> function) +NativeFunction* NativeFunction::create(Realm& realm, FlyString const& name, SafeFunction(VM&)> function) { return realm.heap().allocate(realm, name, move(function), *realm.intrinsics().function_prototype()); } -NativeFunction::NativeFunction(Function(VM&)> native_function, Object* prototype, Realm& realm) +NativeFunction::NativeFunction(SafeFunction(VM&)> native_function, Object* prototype, Realm& realm) : FunctionObject(realm, prototype) , m_native_function(move(native_function)) , m_realm(&realm) @@ -73,7 +73,7 @@ NativeFunction::NativeFunction(Object& prototype) { } -NativeFunction::NativeFunction(FlyString name, Function(VM&)> native_function, Object& prototype) +NativeFunction::NativeFunction(FlyString name, SafeFunction(VM&)> native_function, Object& prototype) : FunctionObject(prototype) , m_name(move(name)) , m_native_function(move(native_function)) diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.h b/Userland/Libraries/LibJS/Runtime/NativeFunction.h index 510a255d42..4e15d89bf5 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.h @@ -8,11 +8,11 @@ #pragma once #include -#include #include #include #include #include +#include namespace JS { @@ -20,8 +20,8 @@ class NativeFunction : public FunctionObject { JS_OBJECT(NativeFunction, FunctionObject); public: - static NativeFunction* create(Realm&, Function(VM&)> behaviour, i32 length, PropertyKey const& name, Optional = {}, Optional prototype = {}, Optional const& prefix = {}); - static NativeFunction* create(Realm&, FlyString const& name, Function(VM&)>); + static NativeFunction* create(Realm&, SafeFunction(VM&)> behaviour, i32 length, PropertyKey const& name, Optional = {}, Optional prototype = {}, Optional const& prefix = {}); + static NativeFunction* create(Realm&, FlyString const& name, SafeFunction(VM&)>); virtual void initialize(Realm&) override { } virtual ~NativeFunction() override = default; @@ -44,8 +44,8 @@ public: protected: NativeFunction(FlyString name, Object& prototype); - NativeFunction(Function(VM&)>, Object* prototype, Realm& realm); - NativeFunction(FlyString name, Function(VM&)>, Object& prototype); + NativeFunction(SafeFunction(VM&)>, Object* prototype, Realm& realm); + NativeFunction(FlyString name, SafeFunction(VM&)>, Object& prototype); explicit NativeFunction(Object& prototype); private: @@ -53,7 +53,7 @@ private: FlyString m_name; Optional m_initial_name; // [[InitialName]] - Function(VM&)> m_native_function; + SafeFunction(VM&)> m_native_function; Realm* m_realm { nullptr }; };