mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:47:46 +00:00
LibJS: Add NativeFunction::create() overload for CreateBuiltinFunction
Also take a length argument and set the name and length properties internally, instead of at the call site. Additionally, allow passing a realm, prototype, and prefix.
This commit is contained in:
parent
e657e88ed6
commit
e4f165d460
2 changed files with 50 additions and 2 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/PropertyKey.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
|
@ -19,9 +20,11 @@ class NativeFunction : public FunctionObject {
|
|||
JS_OBJECT(NativeFunction, FunctionObject);
|
||||
|
||||
public:
|
||||
static NativeFunction* create(GlobalObject&, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> behaviour, i32 length, PropertyKey const& name, Optional<Realm*> = {}, Optional<Object*> prototype = {}, Optional<StringView> const& prefix = {});
|
||||
static NativeFunction* create(GlobalObject&, const FlyString& name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>);
|
||||
|
||||
explicit NativeFunction(FlyString name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>, Object& prototype);
|
||||
NativeFunction(GlobalObject&, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>, Object* prototype, Realm& realm);
|
||||
NativeFunction(FlyString name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>, Object& prototype);
|
||||
virtual void initialize(GlobalObject&) override { }
|
||||
virtual ~NativeFunction() override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue