mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
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.
This commit is contained in:
parent
e915155ca4
commit
a6b8291a9b
81 changed files with 246 additions and 275 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue