mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:57: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
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibJS/Runtime/ArrayBuffer.h>
|
||||
#include <LibJS/Runtime/ByteLength.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
|
@ -17,22 +18,32 @@ class DataView : public Object {
|
|||
JS_DECLARE_ALLOCATOR(DataView);
|
||||
|
||||
public:
|
||||
static NonnullGCPtr<DataView> create(Realm&, ArrayBuffer*, size_t byte_length, size_t byte_offset);
|
||||
static NonnullGCPtr<DataView> create(Realm&, ArrayBuffer*, ByteLength byte_length, size_t byte_offset);
|
||||
|
||||
virtual ~DataView() override = default;
|
||||
|
||||
ArrayBuffer* viewed_array_buffer() const { return m_viewed_array_buffer; }
|
||||
size_t byte_length() const { return m_byte_length; }
|
||||
ByteLength const& byte_length() const { return m_byte_length; }
|
||||
size_t byte_offset() const { return m_byte_offset; }
|
||||
|
||||
private:
|
||||
DataView(ArrayBuffer*, size_t byte_length, size_t byte_offset, Object& prototype);
|
||||
DataView(ArrayBuffer*, ByteLength byte_length, size_t byte_offset, Object& prototype);
|
||||
|
||||
virtual void visit_edges(Visitor& visitor) override;
|
||||
|
||||
GCPtr<ArrayBuffer> m_viewed_array_buffer;
|
||||
size_t m_byte_length { 0 };
|
||||
ByteLength m_byte_length { 0 };
|
||||
size_t m_byte_offset { 0 };
|
||||
};
|
||||
|
||||
// 25.3.1.1 DataView With Buffer Witness Records, https://tc39.es/ecma262/#sec-dataview-with-buffer-witness-records
|
||||
struct DataViewWithBufferWitness {
|
||||
NonnullGCPtr<DataView const> object; // [[Object]]
|
||||
ByteLength cached_buffer_byte_length; // [[CachedBufferByteLength]]
|
||||
};
|
||||
|
||||
DataViewWithBufferWitness make_data_view_with_buffer_witness_record(DataView const&, ArrayBuffer::Order);
|
||||
u32 get_view_byte_length(DataViewWithBufferWitness const&);
|
||||
bool is_view_out_of_bounds(DataViewWithBufferWitness const&);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue