From 5b2255291edc4761869f30b067404139fc0268b6 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 13 Jun 2021 20:15:19 +0100 Subject: [PATCH] LibJS: Make a couple of %TypedArray%.prototype properties accessors Also use JS_DEFINE_NATIVE_GETTER and not JS_DEFINE_NATIVE_FUNCTION for their function definitions. --- .../LibJS/Runtime/TypedArrayPrototype.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index eb10d24ace..fa4f04bf8e 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -21,11 +21,10 @@ void TypedArrayPrototype::initialize(GlobalObject& object) Object::initialize(object); u8 attr = Attribute::Writable | Attribute::Configurable; - // FIXME: This should be an accessor property - define_native_property(vm.names.length, length_getter, nullptr, Attribute::Configurable); - define_native_property(vm.names.buffer, buffer_getter, nullptr, Attribute::Configurable); - define_native_property(vm.names.byteLength, byte_length_getter, nullptr, Attribute::Configurable); - define_native_property(vm.names.byteOffset, byte_offset_getter, nullptr, Attribute::Configurable); + define_native_accessor(vm.names.length, length_getter, nullptr, Attribute::Configurable); + define_native_accessor(vm.names.buffer, buffer_getter, nullptr, Attribute::Configurable); + define_native_accessor(vm.names.byteLength, byte_length_getter, nullptr, Attribute::Configurable); + define_native_accessor(vm.names.byteOffset, byte_offset_getter, nullptr, Attribute::Configurable); define_native_function(vm.names.at, at, 1, attr); } @@ -83,7 +82,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::at) } // 23.2.3.1 get %TypedArray%.prototype.buffer, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.buffer -JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::buffer_getter) +JS_DEFINE_NATIVE_GETTER(TypedArrayPrototype::buffer_getter) { auto typed_array = typed_array_from(vm, global_object); if (!typed_array) @@ -94,7 +93,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::buffer_getter) } // 23.2.3.2 get %TypedArray%.prototype.byteLength, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.bytelength -JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::byte_length_getter) +JS_DEFINE_NATIVE_GETTER(TypedArrayPrototype::byte_length_getter) { auto typed_array = typed_array_from(vm, global_object); if (!typed_array) @@ -107,7 +106,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::byte_length_getter) } // 23.2.3.3 get %TypedArray%.prototype.byteOffset, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.byteoffset -JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::byte_offset_getter) +JS_DEFINE_NATIVE_GETTER(TypedArrayPrototype::byte_offset_getter) { auto typed_array = typed_array_from(vm, global_object); if (!typed_array)