1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:27:35 +00:00

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.
This commit is contained in:
Linus Groh 2021-06-13 20:15:19 +01:00
parent 5c1af1d6f7
commit 5b2255291e

View file

@ -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)