mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:57:35 +00:00
LibJS: Rename Function => FunctionObject
This commit is contained in:
parent
e389ae3c97
commit
ba9d5c4d54
114 changed files with 263 additions and 262 deletions
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/EventListenerWrapper.h>
|
||||
#include <LibWeb/DOM/EventListener.h>
|
||||
|
|
|
@ -40,7 +40,7 @@ JS::Value ImageConstructor::call()
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-image
|
||||
JS::Value ImageConstructor::construct(Function&)
|
||||
JS::Value ImageConstructor::construct(FunctionObject&)
|
||||
{
|
||||
auto& window = static_cast<WindowObject&>(global_object());
|
||||
auto& document = window.impl().document();
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
virtual ~ImageConstructor() override;
|
||||
|
||||
virtual JS::Value call() override;
|
||||
virtual JS::Value construct(JS::Function& new_target) override;
|
||||
virtual JS::Value construct(JS::FunctionObject& new_target) override;
|
||||
|
||||
private:
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/Shape.h>
|
||||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Bindings/DocumentWrapper.h>
|
||||
|
@ -192,7 +192,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::set_interval)
|
|||
interval = 0;
|
||||
}
|
||||
|
||||
auto timer_id = impl->set_interval(*static_cast<JS::Function*>(callback_object), interval);
|
||||
auto timer_id = impl->set_interval(*static_cast<JS::FunctionObject*>(callback_object), interval);
|
||||
return JS::Value(timer_id);
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::set_timeout)
|
|||
interval = 0;
|
||||
}
|
||||
|
||||
auto timer_id = impl->set_timeout(*static_cast<JS::Function*>(callback_object), interval);
|
||||
auto timer_id = impl->set_timeout(*static_cast<JS::FunctionObject*>(callback_object), interval);
|
||||
return JS::Value(timer_id);
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::request_animation_frame)
|
|||
vm.throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotAFunctionNoParam);
|
||||
return {};
|
||||
}
|
||||
return JS::Value(impl->request_animation_frame(*static_cast<JS::Function*>(callback_object)));
|
||||
return JS::Value(impl->request_animation_frame(*static_cast<JS::FunctionObject*>(callback_object)));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::cancel_animation_frame)
|
||||
|
|
|
@ -854,7 +854,7 @@ void generate_implementation(const IDL::Interface& interface)
|
|||
#include <AK/FlyString.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/TypedArray.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
@ -968,7 +968,7 @@ public:
|
|||
virtual ~@constructor_class@() override;
|
||||
|
||||
virtual JS::Value call() override;
|
||||
virtual JS::Value construct(JS::Function& new_target) override;
|
||||
virtual JS::Value construct(JS::FunctionObject& new_target) override;
|
||||
|
||||
private:
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
|
@ -1040,7 +1040,7 @@ JS::Value @constructor_class@::call()
|
|||
return {};
|
||||
}
|
||||
|
||||
JS::Value @constructor_class@::construct(Function&)
|
||||
JS::Value @constructor_class@::construct(FunctionObject&)
|
||||
{
|
||||
)~~~");
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ void generate_prototype_implementation(const IDL::Interface& interface)
|
|||
#include <AK/Function.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/TypedArray.h>
|
||||
#include <LibWeb/Bindings/@prototype_class@.h>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <LibCore/Timer.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Parser.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/CSS/StyleResolver.h>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibWeb/Bindings/EventTargetWrapper.h>
|
||||
#include <LibWeb/Bindings/EventTargetWrapperFactory.h>
|
||||
#include <LibWeb/Bindings/EventWrapper.h>
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibWeb/DOM/EventListener.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
JS::Function& EventListener::function()
|
||||
JS::FunctionObject& EventListener::function()
|
||||
{
|
||||
VERIFY(m_function.cell());
|
||||
return *m_function.cell();
|
||||
|
|
|
@ -18,13 +18,13 @@ class EventListener
|
|||
public:
|
||||
using WrapperType = Bindings::EventListenerWrapper;
|
||||
|
||||
explicit EventListener(JS::Handle<JS::Function> function, bool is_attribute = false)
|
||||
explicit EventListener(JS::Handle<JS::FunctionObject> function, bool is_attribute = false)
|
||||
: m_function(move(function))
|
||||
, m_attribute(is_attribute)
|
||||
{
|
||||
}
|
||||
|
||||
JS::Function& function();
|
||||
JS::FunctionObject& function();
|
||||
|
||||
const FlyString& type() const { return m_type; }
|
||||
void set_type(const FlyString& type) { m_type = type; }
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
private:
|
||||
FlyString m_type;
|
||||
JS::Handle<JS::Function> m_function;
|
||||
JS::Handle<JS::FunctionObject> m_function;
|
||||
bool m_capture { false };
|
||||
bool m_passive { false };
|
||||
bool m_once { false };
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibWeb/Bindings/EventWrapper.h>
|
||||
#include <LibWeb/Bindings/NodeWrapper.h>
|
||||
#include <LibWeb/Bindings/NodeWrapperFactory.h>
|
||||
|
|
|
@ -5,23 +5,23 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibWeb/DOM/Timer.h>
|
||||
#include <LibWeb/DOM/Window.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
NonnullRefPtr<Timer> Timer::create_interval(Window& window, int milliseconds, JS::Function& callback)
|
||||
NonnullRefPtr<Timer> Timer::create_interval(Window& window, int milliseconds, JS::FunctionObject& callback)
|
||||
{
|
||||
return adopt_ref(*new Timer(window, Type::Interval, milliseconds, callback));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Timer> Timer::create_timeout(Window& window, int milliseconds, JS::Function& callback)
|
||||
NonnullRefPtr<Timer> Timer::create_timeout(Window& window, int milliseconds, JS::FunctionObject& callback)
|
||||
{
|
||||
return adopt_ref(*new Timer(window, Type::Timeout, milliseconds, callback));
|
||||
}
|
||||
|
||||
Timer::Timer(Window& window, Type type, int milliseconds, JS::Function& callback)
|
||||
Timer::Timer(Window& window, Type type, int milliseconds, JS::FunctionObject& callback)
|
||||
: m_window(window)
|
||||
, m_type(type)
|
||||
, m_callback(JS::make_handle(&callback))
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <AK/Forward.h>
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
@ -21,24 +21,24 @@ public:
|
|||
Timeout,
|
||||
};
|
||||
|
||||
static NonnullRefPtr<Timer> create_interval(Window&, int milliseconds, JS::Function&);
|
||||
static NonnullRefPtr<Timer> create_timeout(Window&, int milliseconds, JS::Function&);
|
||||
static NonnullRefPtr<Timer> create_interval(Window&, int milliseconds, JS::FunctionObject&);
|
||||
static NonnullRefPtr<Timer> create_timeout(Window&, int milliseconds, JS::FunctionObject&);
|
||||
|
||||
~Timer();
|
||||
|
||||
i32 id() const { return m_id; }
|
||||
Type type() const { return m_type; }
|
||||
|
||||
JS::Function& callback() { return *m_callback.cell(); }
|
||||
JS::FunctionObject& callback() { return *m_callback.cell(); }
|
||||
|
||||
private:
|
||||
Timer(Window&, Type, int ms, JS::Function&);
|
||||
Timer(Window&, Type, int ms, JS::FunctionObject&);
|
||||
|
||||
Window& m_window;
|
||||
RefPtr<Core::Timer> m_timer;
|
||||
Type m_type;
|
||||
int m_id { 0 };
|
||||
JS::Handle<JS::Function> m_callback;
|
||||
JS::Handle<JS::FunctionObject> m_callback;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibGUI/DisplayLink.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/EventDispatcher.h>
|
||||
|
@ -60,14 +60,14 @@ String Window::prompt(const String& message, const String& default_)
|
|||
return {};
|
||||
}
|
||||
|
||||
i32 Window::set_interval(JS::Function& callback, i32 interval)
|
||||
i32 Window::set_interval(JS::FunctionObject& callback, i32 interval)
|
||||
{
|
||||
auto timer = Timer::create_interval(*this, interval, callback);
|
||||
m_timers.set(timer->id(), timer);
|
||||
return timer->id();
|
||||
}
|
||||
|
||||
i32 Window::set_timeout(JS::Function& callback, i32 interval)
|
||||
i32 Window::set_timeout(JS::FunctionObject& callback, i32 interval)
|
||||
{
|
||||
auto timer = Timer::create_timeout(*this, interval, callback);
|
||||
m_timers.set(timer->id(), timer);
|
||||
|
@ -112,13 +112,13 @@ void Window::clear_interval(i32 timer_id)
|
|||
m_timers.remove(timer_id);
|
||||
}
|
||||
|
||||
i32 Window::request_animation_frame(JS::Function& callback)
|
||||
i32 Window::request_animation_frame(JS::FunctionObject& callback)
|
||||
{
|
||||
// FIXME: This is extremely fake!
|
||||
static double fake_timestamp = 0;
|
||||
|
||||
i32 link_id = GUI::DisplayLink::register_callback([handle = make_handle(&callback)](i32 link_id) {
|
||||
auto& function = const_cast<JS::Function&>(static_cast<const JS::Function&>(*handle.cell()));
|
||||
auto& function = const_cast<JS::FunctionObject&>(static_cast<const JS::FunctionObject&>(*handle.cell()));
|
||||
auto& vm = function.vm();
|
||||
fake_timestamp += 10;
|
||||
[[maybe_unused]] auto rc = vm.call(function, JS::js_undefined(), JS::Value(fake_timestamp));
|
||||
|
|
|
@ -39,11 +39,11 @@ public:
|
|||
void alert(const String&);
|
||||
bool confirm(const String&);
|
||||
String prompt(const String&, const String&);
|
||||
i32 request_animation_frame(JS::Function&);
|
||||
i32 request_animation_frame(JS::FunctionObject&);
|
||||
void cancel_animation_frame(i32);
|
||||
|
||||
i32 set_timeout(JS::Function&, i32);
|
||||
i32 set_interval(JS::Function&, i32);
|
||||
i32 set_timeout(JS::FunctionObject&, i32);
|
||||
i32 set_interval(JS::FunctionObject&, i32);
|
||||
void clear_timeout(i32);
|
||||
void clear_interval(i32);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -22,13 +22,13 @@ struct EventHandler {
|
|||
{
|
||||
}
|
||||
|
||||
EventHandler(JS::Handle<JS::Function> c)
|
||||
EventHandler(JS::Handle<JS::FunctionObject> c)
|
||||
: callback(move(c))
|
||||
{
|
||||
}
|
||||
|
||||
String string;
|
||||
JS::Handle<JS::Function> callback;
|
||||
JS::Handle<JS::FunctionObject> callback;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ void GlobalEventHandlers::set_event_handler_attribute(const FlyString& name, HTM
|
|||
}
|
||||
auto* function = JS::ScriptFunction::create(self.script_execution_context()->interpreter().global_object(), name, program->body(), program->parameters(), program->function_length(), nullptr, JS::FunctionKind::Regular, false, false);
|
||||
VERIFY(function);
|
||||
listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast<JS::Function*>(function))));
|
||||
listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast<JS::FunctionObject*>(function))));
|
||||
}
|
||||
if (listener) {
|
||||
for (auto& registered_listener : self.listeners()) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Parser.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/ScriptFunction.h>
|
||||
#include <LibProtocol/WebSocket.h>
|
||||
#include <LibProtocol/WebSocketClient.h>
|
||||
|
@ -248,7 +248,7 @@ void WebSocket::set_event_handler_attribute(const FlyString& name, HTML::EventHa
|
|||
}
|
||||
auto* function = JS::ScriptFunction::create(script_execution_context()->interpreter().global_object(), name, program->body(), program->parameters(), program->function_length(), nullptr, JS::FunctionKind::Regular, false, false);
|
||||
VERIFY(function);
|
||||
listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast<JS::Function*>(function))));
|
||||
listener = adopt_ref(*new DOM::EventListener(JS::make_handle(static_cast<JS::FunctionObject*>(function))));
|
||||
}
|
||||
if (listener) {
|
||||
for (auto& registered_listener : listeners()) {
|
||||
|
|
|
@ -28,7 +28,7 @@ JS::Value WebAssemblyMemoryConstructor::call()
|
|||
return {};
|
||||
}
|
||||
|
||||
JS::Value WebAssemblyMemoryConstructor::construct(Function&)
|
||||
JS::Value WebAssemblyMemoryConstructor::construct(FunctionObject&)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
virtual ~WebAssemblyMemoryConstructor() override;
|
||||
|
||||
virtual JS::Value call() override;
|
||||
virtual JS::Value construct(JS::Function& new_target) override;
|
||||
virtual JS::Value construct(JS::FunctionObject& new_target) override;
|
||||
|
||||
private:
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
// so ideally this would be a refcounted object, shared between
|
||||
// WebAssemblyModuleObject's and WebAssemblyInstantiatedModuleObject's.
|
||||
struct ModuleCache {
|
||||
HashMap<Wasm::FunctionAddress, JS::Function*> function_instances;
|
||||
HashMap<Wasm::FunctionAddress, JS::FunctionObject*> function_instances;
|
||||
HashMap<Wasm::MemoryAddress, WebAssemblyMemoryObject*> memory_instances;
|
||||
};
|
||||
struct GlobalModuleCache {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibWeb/Bindings/EventWrapper.h>
|
||||
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue