mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
LibJS+LibWeb: Implement resizable ArrayBuffer support for DataView
This is (part of) a normative change in the ECMA-262 spec. See:
a9ae96e
This commit is contained in:
parent
29ac6e3689
commit
c7fec9424c
12 changed files with 377 additions and 94 deletions
|
@ -480,14 +480,22 @@ ErrorOr<void> print_typed_array(JS::PrintContext& print_context, JS::TypedArrayB
|
|||
|
||||
ErrorOr<void> print_data_view(JS::PrintContext& print_context, JS::DataView const& data_view, HashTable<JS::Object*>& seen_objects)
|
||||
{
|
||||
auto view_record = JS::make_data_view_with_buffer_witness_record(data_view, JS::ArrayBuffer::Order::SeqCst);
|
||||
TRY(print_type(print_context, "DataView"sv));
|
||||
TRY(js_out(print_context, "\n byteLength: "));
|
||||
TRY(print_value(print_context, JS::Value(data_view.byte_length()), seen_objects));
|
||||
TRY(js_out(print_context, "\n byteOffset: "));
|
||||
TRY(print_value(print_context, JS::Value(data_view.byte_offset()), seen_objects));
|
||||
|
||||
TRY(js_out(print_context, "\n buffer: "));
|
||||
TRY(print_type(print_context, "ArrayBuffer"sv));
|
||||
TRY(js_out(print_context, " @ {:p}", data_view.viewed_array_buffer()));
|
||||
|
||||
if (JS::is_view_out_of_bounds(view_record)) {
|
||||
TRY(js_out(print_context, "\n <out of bounds>"));
|
||||
return {};
|
||||
}
|
||||
|
||||
TRY(js_out(print_context, "\n byteLength: "));
|
||||
TRY(print_value(print_context, JS::Value(JS::get_view_byte_length(view_record)), seen_objects));
|
||||
TRY(js_out(print_context, "\n byteOffset: "));
|
||||
TRY(print_value(print_context, JS::Value(data_view.byte_offset()), seen_objects));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue