mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
LibWeb: Remove unecessary dependence on Window from WebAssembly classes
These classes only needed Window to get at its realm. Pass a realm directly to construct WebAssembly classes.
This commit is contained in:
parent
320dddde6a
commit
d0efc7734a
8 changed files with 22 additions and 29 deletions
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibJS/Runtime/GlobalObject.h>
|
#include <LibJS/Runtime/GlobalObject.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h>
|
#include <LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyInstanceObject.h>
|
#include <LibWeb/WebAssembly/WebAssemblyInstanceObject.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h>
|
#include <LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h>
|
||||||
|
@ -42,10 +42,9 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyInstanceConstructor::construct(Fun
|
||||||
void WebAssemblyInstanceConstructor::initialize(JS::Realm& realm)
|
void WebAssemblyInstanceConstructor::initialize(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
|
||||||
|
|
||||||
NativeFunction::initialize(realm);
|
NativeFunction::initialize(realm);
|
||||||
define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype"), 0);
|
define_direct_property(vm.names.prototype, &Bindings::ensure_web_prototype<WebAssemblyInstancePrototype>(realm, "WebAssemblyInstancePrototype"), 0);
|
||||||
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <LibJS/Runtime/BigInt.h>
|
#include <LibJS/Runtime/BigInt.h>
|
||||||
#include <LibJS/Runtime/TypedArray.h>
|
#include <LibJS/Runtime/TypedArray.h>
|
||||||
#include <LibWasm/AbstractMachine/Interpreter.h>
|
#include <LibWasm/AbstractMachine/Interpreter.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyInstanceObject.h>
|
#include <LibWeb/WebAssembly/WebAssemblyInstanceObject.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h>
|
#include <LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
WebAssemblyInstanceObject::WebAssemblyInstanceObject(JS::Realm& realm, size_t index)
|
WebAssemblyInstanceObject::WebAssemblyInstanceObject(JS::Realm& realm, size_t index)
|
||||||
: Object(static_cast<Web::HTML::Window&>(realm.global_object()).ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype"))
|
: Object(Bindings::ensure_web_prototype<WebAssemblyInstancePrototype>(realm, "WebAssemblyInstancePrototype"))
|
||||||
, m_index(index)
|
, m_index(index)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibJS/Runtime/GlobalObject.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h>
|
#include <LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h>
|
#include <LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
||||||
|
@ -53,10 +52,9 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyMemoryConstructor::construct(Funct
|
||||||
void WebAssemblyMemoryConstructor::initialize(JS::Realm& realm)
|
void WebAssemblyMemoryConstructor::initialize(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
|
||||||
|
|
||||||
NativeFunction::initialize(realm);
|
NativeFunction::initialize(realm);
|
||||||
define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype"), 0);
|
define_direct_property(vm.names.prototype, &Bindings::ensure_web_prototype<WebAssemblyMemoryPrototype>(realm, "WebAssemblyMemoryPrototype"), 0);
|
||||||
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibJS/Runtime/GlobalObject.h>
|
|
||||||
#include <LibJS/Runtime/TypedArray.h>
|
#include <LibJS/Runtime/TypedArray.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyModuleConstructor.h>
|
#include <LibWeb/WebAssembly/WebAssemblyModuleConstructor.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyModuleObject.h>
|
#include <LibWeb/WebAssembly/WebAssemblyModuleObject.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyModulePrototype.h>
|
#include <LibWeb/WebAssembly/WebAssemblyModulePrototype.h>
|
||||||
|
@ -40,10 +39,9 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyModuleConstructor::construct(Funct
|
||||||
void WebAssemblyModuleConstructor::initialize(JS::Realm& realm)
|
void WebAssemblyModuleConstructor::initialize(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
|
||||||
|
|
||||||
NativeFunction::initialize(realm);
|
NativeFunction::initialize(realm);
|
||||||
define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype"), 0);
|
define_direct_property(vm.names.prototype, &Bindings::ensure_web_prototype<WebAssemblyModulePrototype>(realm, "WebAssemblyModulePrototype"), 0);
|
||||||
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
WebAssemblyModuleObject::WebAssemblyModuleObject(JS::Realm& realm, size_t index)
|
WebAssemblyModuleObject::WebAssemblyModuleObject(JS::Realm& realm, size_t index)
|
||||||
: Object(verify_cast<HTML::Window>(realm.global_object()).ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype"))
|
: Object(Bindings::ensure_web_prototype<WebAssemblyModulePrototype>(realm, "WebAssemblyModulePrototype"))
|
||||||
, m_index(index)
|
, m_index(index)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <LibJS/Runtime/TypedArray.h>
|
#include <LibJS/Runtime/TypedArray.h>
|
||||||
#include <LibWasm/AbstractMachine/Interpreter.h>
|
#include <LibWasm/AbstractMachine/Interpreter.h>
|
||||||
#include <LibWasm/AbstractMachine/Validator.h>
|
#include <LibWasm/AbstractMachine/Validator.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h>
|
#include <LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
||||||
|
|
||||||
|
@ -42,28 +42,27 @@ void WebAssemblyObject::initialize(JS::Realm& realm)
|
||||||
|
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
|
|
||||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
auto& memory_constructor = Bindings::ensure_web_constructor<WebAssemblyMemoryConstructor>(realm, "WebAssembly.Memory");
|
||||||
auto& memory_constructor = window.ensure_web_constructor<WebAssemblyMemoryConstructor>("WebAssembly.Memory");
|
|
||||||
memory_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Memory"), JS::Attribute::Configurable);
|
memory_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Memory"), JS::Attribute::Configurable);
|
||||||
auto& memory_prototype = window.ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype");
|
auto& memory_prototype = Bindings::ensure_web_prototype<WebAssemblyMemoryPrototype>(realm, "WebAssemblyMemoryPrototype");
|
||||||
memory_prototype.define_direct_property(vm.names.constructor, &memory_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
memory_prototype.define_direct_property(vm.names.constructor, &memory_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||||
define_direct_property("Memory", &memory_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
define_direct_property("Memory", &memory_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||||
|
|
||||||
auto& instance_constructor = window.ensure_web_constructor<WebAssemblyInstanceConstructor>("WebAssembly.Instance");
|
auto& instance_constructor = Bindings::ensure_web_constructor<WebAssemblyInstanceConstructor>(realm, "WebAssembly.Instance");
|
||||||
instance_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Instance"), JS::Attribute::Configurable);
|
instance_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Instance"), JS::Attribute::Configurable);
|
||||||
auto& instance_prototype = window.ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype");
|
auto& instance_prototype = Bindings::ensure_web_prototype<WebAssemblyInstancePrototype>(realm, "WebAssemblyInstancePrototype");
|
||||||
instance_prototype.define_direct_property(vm.names.constructor, &instance_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
instance_prototype.define_direct_property(vm.names.constructor, &instance_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||||
define_direct_property("Instance", &instance_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
define_direct_property("Instance", &instance_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||||
|
|
||||||
auto& module_constructor = window.ensure_web_constructor<WebAssemblyModuleConstructor>("WebAssembly.Module");
|
auto& module_constructor = Bindings::ensure_web_constructor<WebAssemblyModuleConstructor>(realm, "WebAssembly.Module");
|
||||||
module_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Module"), JS::Attribute::Configurable);
|
module_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Module"), JS::Attribute::Configurable);
|
||||||
auto& module_prototype = window.ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype");
|
auto& module_prototype = Bindings::ensure_web_prototype<WebAssemblyModulePrototype>(realm, "WebAssemblyModulePrototype");
|
||||||
module_prototype.define_direct_property(vm.names.constructor, &module_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
module_prototype.define_direct_property(vm.names.constructor, &module_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||||
define_direct_property("Module", &module_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
define_direct_property("Module", &module_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||||
|
|
||||||
auto& table_constructor = window.ensure_web_constructor<WebAssemblyTableConstructor>("WebAssembly.Table");
|
auto& table_constructor = Bindings::ensure_web_constructor<WebAssemblyTableConstructor>(realm, "WebAssembly.Table");
|
||||||
table_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Table"), JS::Attribute::Configurable);
|
table_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Table"), JS::Attribute::Configurable);
|
||||||
auto& table_prototype = window.ensure_web_prototype<WebAssemblyTablePrototype>("WebAssemblyTablePrototype");
|
auto& table_prototype = Bindings::ensure_web_prototype<WebAssemblyTablePrototype>(realm, "WebAssemblyTablePrototype");
|
||||||
table_prototype.define_direct_property(vm.names.constructor, &table_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
table_prototype.define_direct_property(vm.names.constructor, &table_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||||
define_direct_property("Table", &table_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
define_direct_property("Table", &table_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
@ -482,7 +481,7 @@ JS::NativeFunction* create_native_function(JS::VM& vm, Wasm::FunctionAddress add
|
||||||
}
|
}
|
||||||
|
|
||||||
WebAssemblyMemoryObject::WebAssemblyMemoryObject(JS::Realm& realm, Wasm::MemoryAddress address)
|
WebAssemblyMemoryObject::WebAssemblyMemoryObject(JS::Realm& realm, Wasm::MemoryAddress address)
|
||||||
: Object(verify_cast<HTML::Window>(realm.global_object()).ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype"))
|
: Object(Bindings::ensure_web_prototype<WebAssemblyMemoryPrototype>(realm, "WebAssemblyMemoryPrototype"))
|
||||||
, m_address(address)
|
, m_address(address)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include <LibJS/Runtime/GlobalObject.h>
|
#include <LibJS/Runtime/GlobalObject.h>
|
||||||
#include <LibJS/Runtime/TypedArray.h>
|
#include <LibJS/Runtime/TypedArray.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyTableConstructor.h>
|
#include <LibWeb/WebAssembly/WebAssemblyTableConstructor.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyTableObject.h>
|
#include <LibWeb/WebAssembly/WebAssemblyTableObject.h>
|
||||||
|
@ -83,10 +83,9 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyTableConstructor::construct(Functi
|
||||||
void WebAssemblyTableConstructor::initialize(JS::Realm& realm)
|
void WebAssemblyTableConstructor::initialize(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
|
||||||
|
|
||||||
NativeFunction::initialize(realm);
|
NativeFunction::initialize(realm);
|
||||||
define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyTablePrototype>("WebAssemblyTablePrototype"), 0);
|
define_direct_property(vm.names.prototype, &Bindings::ensure_web_prototype<WebAssemblyTablePrototype>(realm, "WebAssemblyTablePrototype"), 0);
|
||||||
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
WebAssemblyTableObject::WebAssemblyTableObject(JS::Realm& realm, Wasm::TableAddress address)
|
WebAssemblyTableObject::WebAssemblyTableObject(JS::Realm& realm, Wasm::TableAddress address)
|
||||||
: Object(verify_cast<HTML::Window>(realm.global_object()).ensure_web_prototype<WebAssemblyTablePrototype>("WebAssemblyTablePrototype"))
|
: Object(Bindings::ensure_web_prototype<WebAssemblyTablePrototype>(realm, "WebAssemblyTablePrototype"))
|
||||||
, m_address(address)
|
, m_address(address)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue