mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 04:37:22 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
67
Libraries/LibJS/Runtime/NativeFunction.h
Normal file
67
Libraries/LibJS/Runtime/NativeFunction.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibJS/Heap/HeapFunction.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/PropertyKey.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
class NativeFunction : public FunctionObject {
|
||||
JS_OBJECT(NativeFunction, FunctionObject);
|
||||
JS_DECLARE_ALLOCATOR(NativeFunction);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<NativeFunction> create(Realm&, ESCAPING Function<ThrowCompletionOr<Value>(VM&)> behaviour, i32 length, PropertyKey const& name, Optional<Realm*> = {}, Optional<Object*> prototype = {}, Optional<StringView> const& prefix = {});
|
||||
static NonnullGCPtr<NativeFunction> create(Realm&, DeprecatedFlyString const& name, ESCAPING Function<ThrowCompletionOr<Value>(VM&)>);
|
||||
|
||||
virtual ~NativeFunction() override = default;
|
||||
|
||||
virtual ThrowCompletionOr<Value> internal_call(Value this_argument, ReadonlySpan<Value> arguments_list) override;
|
||||
virtual ThrowCompletionOr<NonnullGCPtr<Object>> internal_construct(ReadonlySpan<Value> arguments_list, FunctionObject& new_target) override;
|
||||
|
||||
// Used for [[Call]] / [[Construct]]'s "...result of evaluating F in a manner that conforms to the specification of F".
|
||||
// Needs to be overridden by all NativeFunctions without an m_native_function.
|
||||
virtual ThrowCompletionOr<Value> call();
|
||||
virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target);
|
||||
|
||||
virtual DeprecatedFlyString const& name() const override { return m_name; }
|
||||
virtual bool is_strict_mode() const override;
|
||||
virtual bool has_constructor() const override { return false; }
|
||||
virtual Realm* realm() const override { return m_realm; }
|
||||
|
||||
Optional<DeprecatedFlyString> const& initial_name() const { return m_initial_name; }
|
||||
void set_initial_name(Badge<FunctionObject>, DeprecatedFlyString initial_name) { m_initial_name = move(initial_name); }
|
||||
|
||||
protected:
|
||||
NativeFunction(DeprecatedFlyString name, Object& prototype);
|
||||
NativeFunction(JS::GCPtr<JS::HeapFunction<ThrowCompletionOr<Value>(VM&)>>, Object* prototype, Realm& realm);
|
||||
NativeFunction(DeprecatedFlyString name, JS::GCPtr<JS::HeapFunction<ThrowCompletionOr<Value>(VM&)>>, Object& prototype);
|
||||
explicit NativeFunction(Object& prototype);
|
||||
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor& visitor) override;
|
||||
|
||||
private:
|
||||
virtual bool is_native_function() const final { return true; }
|
||||
|
||||
DeprecatedFlyString m_name;
|
||||
GCPtr<PrimitiveString> m_name_string;
|
||||
Optional<DeprecatedFlyString> m_initial_name; // [[InitialName]]
|
||||
JS::GCPtr<JS::HeapFunction<ThrowCompletionOr<Value>(VM&)>> m_native_function;
|
||||
GCPtr<Realm> m_realm;
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool Object::fast_is<NativeFunction>() const { return is_native_function(); }
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue