summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/WebAssembly
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-07-06 02:15:08 +0300
committerLinus Groh <mail@linusgroh.de>2021-07-06 14:20:30 +0100
commita6b8291a9b3f72c6c70141dafb85d380a68ebdd0 (patch)
tree908ed08ffe0d308d926fe0c605983e25148335cf /Userland/Libraries/LibWeb/WebAssembly
parente915155ca452bb9c731051030b0cbb6883d4809d (diff)
downloadserenity-a6b8291a9b3f72c6c70141dafb85d380a68ebdd0.zip
LibJS: Add define_direct_property and remove the define_property helper
This removes all usages of the non-standard define_property helper method and replaces all it's usages with the specification required alternative or with define_direct_property where appropriate.
Diffstat (limited to 'Userland/Libraries/LibWeb/WebAssembly')
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp4
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp4
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp4
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp4
-rw-r--r--Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp25
5 files changed, 21 insertions, 20 deletions
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp
index b74870e368..8b2e990e68 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp
@@ -59,8 +59,8 @@ void WebAssemblyInstanceConstructor::initialize(JS::GlobalObject& global_object)
auto& window = static_cast<WindowObject&>(global_object);
NativeFunction::initialize(global_object);
- define_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype"));
- define_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
+ define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype"), 0);
+ define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
}
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp
index 96d42f3f41..a9931a6f23 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp
@@ -39,7 +39,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object)
object = create_native_function(address, export_.name(), global_object);
cache.function_instances.set(address, *object);
}
- m_exports_object->define_property(export_.name(), *object);
+ m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes);
},
[&](const Wasm::MemoryAddress& address) {
auto object = cache.memory_instances.get(address);
@@ -47,7 +47,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object)
object = heap().allocate<Web::Bindings::WebAssemblyMemoryObject>(global_object, global_object, address);
cache.memory_instances.set(address, *object);
}
- m_exports_object->define_property(export_.name(), *object);
+ m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes);
},
[&](const auto&) {
// FIXME: Implement other exports!
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp
index 625a76ee35..111993a5de 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp
@@ -72,8 +72,8 @@ void WebAssemblyMemoryConstructor::initialize(JS::GlobalObject& global_object)
auto& window = static_cast<WindowObject&>(global_object);
NativeFunction::initialize(global_object);
- define_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype"));
- define_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
+ define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype"), 0);
+ define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
}
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp
index 59c7532910..b998fce270 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp
@@ -54,8 +54,8 @@ void WebAssemblyModuleConstructor::initialize(JS::GlobalObject& global_object)
auto& window = static_cast<WindowObject&>(global_object);
NativeFunction::initialize(global_object);
- define_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype"));
- define_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
+ define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype"), 0);
+ define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
}
}
diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp
index 1c298bdbad..2dee5ffe2d 100644
--- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp
+++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp
@@ -31,30 +31,31 @@ void WebAssemblyObject::initialize(JS::GlobalObject& global_object)
{
Object::initialize(global_object);
- define_native_function("validate", validate, 1);
- define_native_function("compile", compile, 1);
- define_native_function("instantiate", instantiate, 1);
+ u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
+ define_native_function("validate", validate, 1, attr);
+ define_native_function("compile", compile, 1, attr);
+ define_native_function("instantiate", instantiate, 1, attr);
auto& vm = global_object.vm();
auto& window = static_cast<WindowObject&>(global_object);
auto& memory_constructor = window.ensure_web_constructor<WebAssemblyMemoryConstructor>("WebAssembly.Memory");
- memory_constructor.define_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");
- memory_prototype.define_property(vm.names.constructor, &memory_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
- define_property("Memory", &memory_constructor);
+ 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);
auto& instance_constructor = window.ensure_web_constructor<WebAssemblyInstanceConstructor>("WebAssembly.Instance");
- instance_constructor.define_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");
- instance_prototype.define_property(vm.names.constructor, &instance_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
- define_property("Instance", &instance_constructor);
+ 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);
auto& module_constructor = window.ensure_web_constructor<WebAssemblyModuleConstructor>("WebAssembly.Module");
- module_constructor.define_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");
- module_prototype.define_property(vm.names.constructor, &module_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
- define_property("Module", &module_constructor);
+ 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);
}
NonnullOwnPtrVector<WebAssemblyObject::CompiledWebAssemblyModule> WebAssemblyObject::s_compiled_modules;