1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 14:37:45 +00:00

LibJS: Turn initialize_global_object() into a regular initialize()

There's nothing special about global object initialization anymore, this
can just work the same way as for any other object now.
This commit is contained in:
Linus Groh 2022-08-28 14:42:50 +01:00
parent 867ad03995
commit cfa5885855
17 changed files with 36 additions and 36 deletions

View file

@ -62,7 +62,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::create_realm)
auto* realm_global_object = vm.heap().allocate_without_realm<GlobalObject>(*realm);
VERIFY(realm_global_object);
realm->set_global_object(realm_global_object, nullptr);
realm_global_object->initialize_global_object(*realm);
realm_global_object->initialize(*realm);
return Value(realm_global_object->$262());
}

View file

@ -14,9 +14,9 @@
namespace JS::Test262 {
void GlobalObject::initialize_global_object(Realm& realm)
void GlobalObject::initialize(Realm& realm)
{
Base::initialize_global_object(realm);
Base::initialize(realm);
m_$262 = vm().heap().allocate<$262Object>(realm, realm);

View file

@ -19,7 +19,7 @@ public:
: JS::GlobalObject(realm)
{
}
virtual void initialize_global_object(Realm&) override;
virtual void initialize(Realm&) override;
virtual ~GlobalObject() override = default;
$262Object* $262() const { return m_$262; }

View file

@ -88,8 +88,10 @@ GlobalObject::GlobalObject(Realm& realm)
}
// 9.3.4 SetDefaultGlobalBindings ( realmRec ), https://tc39.es/ecma262/#sec-setdefaultglobalbindings
void GlobalObject::initialize_global_object(Realm& realm)
void GlobalObject::initialize(Realm& realm)
{
Base::initialize(realm);
auto& vm = this->vm();
ensure_shape_is_unique();

View file

@ -18,8 +18,7 @@ class GlobalObject : public Object {
public:
explicit GlobalObject(Realm&);
virtual void initialize_global_object(Realm&);
virtual void initialize(Realm&) override;
virtual ~GlobalObject() override;
private:

View file

@ -75,7 +75,7 @@ ThrowCompletionOr<NonnullOwnPtr<ExecutionContext>> Realm::initialize_host_define
// 10. Let globalObj be ? SetDefaultGlobalBindings(realm).
// 11. Create any host-defined global object properties on globalObj.
realm->global_object().initialize_global_object(*realm);
realm->global_object().initialize(*realm);
// 12. Return unused.
return new_context;

View file

@ -64,7 +64,7 @@ ThrowCompletionOr<Object*> ShadowRealmConstructor::construct(FunctionObject& new
// 10. Perform ? SetRealmGlobalObject(realmRec, undefined, undefined).
auto* new_global_object = vm.heap().allocate_without_realm<GlobalObject>(*realm);
realm->set_global_object(new_global_object, nullptr);
new_global_object->initialize_global_object(*realm);
new_global_object->initialize(*realm);
// TODO: I don't think we should have these exactly like this, that doesn't work well with how
// we create global objects. Still, it should be possible to make a ShadowRealm with a

View file

@ -194,15 +194,14 @@ public:
: JS::GlobalObject(realm)
{
}
virtual void initialize(JS::Realm&) override;
virtual ~TestRunnerGlobalObject() override = default;
virtual void initialize_global_object(JS::Realm&) override;
};
inline void TestRunnerGlobalObject::initialize_global_object(JS::Realm& realm)
inline void TestRunnerGlobalObject::initialize(JS::Realm& realm)
{
Base::initialize_global_object(realm);
Base::initialize(realm);
define_direct_property("global", this, JS::Attribute::Enumerable);
for (auto& entry : s_exposed_global_functions) {
define_native_function(

View file

@ -57,9 +57,9 @@ WindowObject::WindowObject(JS::Realm& realm, HTML::Window& impl)
impl.set_wrapper({}, *this);
}
void WindowObject::initialize_global_object(JS::Realm& realm)
void WindowObject::initialize(JS::Realm& realm)
{
Base::initialize_global_object(realm);
Base::initialize(realm);
Object::set_prototype(&ensure_web_prototype<WindowPrototype>("Window"));

View file

@ -33,7 +33,7 @@ class WindowObject
public:
explicit WindowObject(JS::Realm&, HTML::Window&);
virtual void initialize_global_object(JS::Realm&) override;
virtual void initialize(JS::Realm&) override;
virtual ~WindowObject() override = default;
HTML::Window& impl() { return *m_impl; }