diff options
author | Linus Groh <mail@linusgroh.de> | 2021-06-13 20:15:19 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-13 21:33:41 +0100 |
commit | 5b2255291edc4761869f30b067404139fc0268b6 (patch) | |
tree | 24a182a8e25c63ae90e1b1b2c6e040217cfc016c /Userland | |
parent | 5c1af1d6f7fbcc475493f4a09508d613c9e2e4d2 (diff) | |
download | serenity-5b2255291edc4761869f30b067404139fc0268b6.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp | 15 |
1 files 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) |