mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:07:34 +00:00
LibJS: Rename Function => FunctionObject
This commit is contained in:
parent
e389ae3c97
commit
ba9d5c4d54
114 changed files with 263 additions and 262 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue