mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:07:46 +00:00
LibJS: Expose TypedArray.prototype.buffer
This commit is contained in:
parent
6f1688279a
commit
8004a2dc77
4 changed files with 45 additions and 0 deletions
|
@ -57,6 +57,7 @@ namespace JS {
|
|||
P(atan2) \
|
||||
P(atanh) \
|
||||
P(bind) \
|
||||
P(buffer) \
|
||||
P(byteLength) \
|
||||
P(call) \
|
||||
P(callee) \
|
||||
|
|
|
@ -23,6 +23,7 @@ void TypedArrayPrototype::initialize(GlobalObject& object)
|
|||
|
||||
// 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_function(vm.names.at, at, 1, attr);
|
||||
}
|
||||
|
||||
|
@ -73,4 +74,15 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::at)
|
|||
return typed_array->get(index.value());
|
||||
}
|
||||
|
||||
// https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.buffer
|
||||
JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::buffer_getter)
|
||||
{
|
||||
auto typed_array = typed_array_from(vm, global_object);
|
||||
if (!typed_array)
|
||||
return {};
|
||||
auto* array_buffer = typed_array->viewed_array_buffer();
|
||||
VERIFY(array_buffer);
|
||||
return Value(array_buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
|
||||
private:
|
||||
JS_DECLARE_NATIVE_GETTER(length_getter);
|
||||
JS_DECLARE_NATIVE_GETTER(buffer_getter);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(at);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue