summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-17 16:52:26 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-17 16:53:35 +0100
commitd792200a5531bf9872e19c7c7a3ba4c865ad43b6 (patch)
tree3c29f8ef40f08033a7bf49d7539e911f97ffd269
parentea81dc13cf961fc7963fc3bc8584479c5f82a55e (diff)
downloadserenity-d792200a5531bf9872e19c7c7a3ba4c865ad43b6.zip
LibJS: Rename GlobalObject::initialize() => initialize_global_object()
This function was shadowing Object::initialize() which cannot be called on global objects and has a different set of parameters.
-rw-r--r--Meta/Lagom/Fuzzers/FuzzilliJs.cpp12
-rw-r--r--Userland/Applications/Spreadsheet/JSIntegration.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/JSIntegration.h2
-rw-r--r--Userland/Applications/Spreadsheet/Spreadsheet.cpp2
-rw-r--r--Userland/Libraries/LibJS/Interpreter.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalObject.h2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/WindowObject.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Bindings/WindowObject.h5
-rw-r--r--Userland/Utilities/js.cpp12
-rw-r--r--Userland/Utilities/test-js.cpp12
11 files changed, 30 insertions, 29 deletions
diff --git a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
index 0256d87368..89e0a75c58 100644
--- a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
@@ -135,16 +135,16 @@ extern "C" void __sanitizer_cov_trace_pc_guard(uint32_t* guard)
// END FUZZING CODE
//
-class TestRunnerGlobalObject : public JS::GlobalObject {
+class TestRunnerGlobalObject final : public JS::GlobalObject {
+ JS_OBJECT(TestRunnerGlobalObject, JS::GlobalObject);
+
public:
TestRunnerGlobalObject();
virtual ~TestRunnerGlobalObject() override;
- virtual void initialize() override;
+ virtual void initialize_global_object() override;
private:
- virtual const char* class_name() const override { return "TestRunnerGlobalObject"; }
-
JS_DECLARE_NATIVE_FUNCTION(fuzzilli);
};
@@ -194,9 +194,9 @@ JS_DEFINE_NATIVE_FUNCTION(TestRunnerGlobalObject::fuzzilli)
return JS::js_undefined();
}
-void TestRunnerGlobalObject::initialize()
+void TestRunnerGlobalObject::initialize_global_object()
{
- JS::GlobalObject::initialize();
+ Base::initialize_global_object();
define_property("global", this, JS::Attribute::Enumerable);
define_native_function("fuzzilli", fuzzilli, 2);
}
diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp
index 834f129fa0..695298f479 100644
--- a/Userland/Applications/Spreadsheet/JSIntegration.cpp
+++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp
@@ -151,9 +151,9 @@ bool SheetGlobalObject::put(const JS::PropertyName& name, JS::Value value, JS::V
return GlobalObject::put(name, value, receiver);
}
-void SheetGlobalObject::initialize()
+void SheetGlobalObject::initialize_global_object()
{
- GlobalObject::initialize();
+ Base::initialize_global_object();
define_native_function("get_real_cell_contents", get_real_cell_contents, 1);
define_native_function("set_real_cell_contents", set_real_cell_contents, 2);
define_native_function("parse_cell_name", parse_cell_name, 1);
diff --git a/Userland/Applications/Spreadsheet/JSIntegration.h b/Userland/Applications/Spreadsheet/JSIntegration.h
index 88f46d929d..9cb7e0bd4c 100644
--- a/Userland/Applications/Spreadsheet/JSIntegration.h
+++ b/Userland/Applications/Spreadsheet/JSIntegration.h
@@ -48,7 +48,7 @@ public:
virtual JS::Value get(const JS::PropertyName&, JS::Value receiver = {}) const override;
virtual bool put(const JS::PropertyName&, JS::Value value, JS::Value receiver = {}) override;
- virtual void initialize() override;
+ virtual void initialize_global_object() override;
JS_DECLARE_NATIVE_FUNCTION(get_real_cell_contents);
JS_DECLARE_NATIVE_FUNCTION(set_real_cell_contents);
diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
index 1ce8c0d3b6..437941f884 100644
--- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp
+++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp
@@ -61,7 +61,7 @@ Sheet::Sheet(Workbook& workbook)
{
JS::DeferGC defer_gc(m_workbook.interpreter().heap());
m_global_object = m_workbook.interpreter().heap().allocate_without_global_object<SheetGlobalObject>(*this);
- global_object().initialize();
+ global_object().initialize_global_object();
global_object().put("workbook", m_workbook.workbook_object());
global_object().put("thisSheet", &global_object()); // Self-reference is unfortunate, but required.
diff --git a/Userland/Libraries/LibJS/Interpreter.h b/Userland/Libraries/LibJS/Interpreter.h
index b84b980662..5efb1428da 100644
--- a/Userland/Libraries/LibJS/Interpreter.h
+++ b/Userland/Libraries/LibJS/Interpreter.h
@@ -53,7 +53,7 @@ public:
auto interpreter = adopt_own(*new Interpreter(vm));
VM::InterpreterExecutionScope scope(*interpreter);
interpreter->m_global_object = make_handle(static_cast<Object*>(interpreter->heap().allocate_without_global_object<GlobalObjectType>(forward<Args>(args)...)));
- static_cast<GlobalObjectType*>(interpreter->m_global_object.cell())->initialize();
+ static_cast<GlobalObjectType*>(interpreter->m_global_object.cell())->initialize_global_object();
return interpreter;
}
diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
index 2b0a01bcc4..e7e0ac9b00 100644
--- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
@@ -82,7 +82,7 @@ GlobalObject::GlobalObject()
{
}
-void GlobalObject::initialize()
+void GlobalObject::initialize_global_object()
{
auto& vm = this->vm();
diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.h b/Userland/Libraries/LibJS/Runtime/GlobalObject.h
index 791bde78ad..6261a23077 100644
--- a/Userland/Libraries/LibJS/Runtime/GlobalObject.h
+++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.h
@@ -37,7 +37,7 @@ class GlobalObject : public ScopeObject {
public:
explicit GlobalObject();
- virtual void initialize();
+ virtual void initialize_global_object();
virtual ~GlobalObject() override;
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp
index 81f1a36d3a..22f17862e6 100644
--- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -56,9 +56,9 @@ WindowObject::WindowObject(DOM::Window& impl)
impl.set_wrapper({}, *this);
}
-void WindowObject::initialize()
+void WindowObject::initialize_global_object()
{
- GlobalObject::initialize();
+ Base::initialize_global_object();
set_prototype(&ensure_web_prototype<EventTargetPrototype>("EventTarget"));
diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.h b/Userland/Libraries/LibWeb/Bindings/WindowObject.h
index 097237bf03..94ffee1795 100644
--- a/Userland/Libraries/LibWeb/Bindings/WindowObject.h
+++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.h
@@ -37,9 +37,11 @@ namespace Bindings {
class WindowObject final
: public JS::GlobalObject
, public Weakable<WindowObject> {
+ JS_OBJECT(WindowObject, JS::GlobalObject);
+
public:
explicit WindowObject(DOM::Window&);
- virtual void initialize() override;
+ virtual void initialize_global_object() override;
virtual ~WindowObject() override;
DOM::Window& impl() { return *m_impl; }
@@ -74,7 +76,6 @@ public:
}
private:
- virtual const char* class_name() const override { return "WindowObject"; }
virtual void visit_edges(Visitor&) override;
JS_DECLARE_NATIVE_GETTER(document_getter);
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 659c5b8c8b..db1f96c64b 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -63,15 +63,15 @@
RefPtr<JS::VM> vm;
Vector<String> repl_statements;
-class ReplObject : public JS::GlobalObject {
+class ReplObject final : public JS::GlobalObject {
+ JS_OBJECT(ReplObject, JS::GlobalObject);
+
public:
ReplObject();
- virtual void initialize() override;
+ virtual void initialize_global_object() override;
virtual ~ReplObject() override;
private:
- virtual const char* class_name() const override { return "ReplObject"; }
-
JS_DECLARE_NATIVE_FUNCTION(exit_interpreter);
JS_DECLARE_NATIVE_FUNCTION(repl_help);
JS_DECLARE_NATIVE_FUNCTION(load_file);
@@ -510,9 +510,9 @@ ReplObject::ReplObject()
{
}
-void ReplObject::initialize()
+void ReplObject::initialize_global_object()
{
- GlobalObject::initialize();
+ Base::initialize_global_object();
define_property("global", this, JS::Attribute::Enumerable);
define_native_function("exit", exit_interpreter);
define_native_function("help", repl_help);
diff --git a/Userland/Utilities/test-js.cpp b/Userland/Utilities/test-js.cpp
index 09ef8a639e..ecb7c9e6e4 100644
--- a/Userland/Utilities/test-js.cpp
+++ b/Userland/Utilities/test-js.cpp
@@ -77,16 +77,16 @@ struct JSTestRunnerCounts {
int files_total { 0 };
};
-class TestRunnerGlobalObject : public JS::GlobalObject {
+class TestRunnerGlobalObject final : public JS::GlobalObject {
+ JS_OBJECT(TestRunnerGlobalObject, JS::GlobalObject);
+
public:
TestRunnerGlobalObject();
virtual ~TestRunnerGlobalObject() override;
- virtual void initialize() override;
+ virtual void initialize_global_object() override;
private:
- virtual const char* class_name() const override { return "TestRunnerGlobalObject"; }
-
JS_DECLARE_NATIVE_FUNCTION(is_strict_mode);
JS_DECLARE_NATIVE_FUNCTION(can_parse_source);
};
@@ -141,9 +141,9 @@ TestRunnerGlobalObject::~TestRunnerGlobalObject()
{
}
-void TestRunnerGlobalObject::initialize()
+void TestRunnerGlobalObject::initialize_global_object()
{
- JS::GlobalObject::initialize();
+ Base::initialize_global_object();
static FlyString global_property_name { "global" };
static FlyString is_strict_mode_property_name { "isStrictMode" };
static FlyString can_parse_source_property_name { "canParseSource" };