mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibJS: Allow creating shared ArrayBuffer objects more easily
This will allow structured deserialization in LibWeb to create shared buffers without having to go through CreateSharedByteDataBlock. That will let us pass in the underlying ByteBuffer, rather than having to allocate a second buffer via CreateSharedByteDataBlock and memcpy the data into it.
This commit is contained in:
parent
3fb4e769d8
commit
b204977efb
Notes:
github-actions[bot]
2025-07-18 14:11:11 +00:00
Author: https://github.com/trflynn89
Commit: b204977efb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5492
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/shannonbooth
2 changed files with 24 additions and 17 deletions
|
@ -59,9 +59,9 @@ class JS_API ArrayBuffer : public Object {
|
|||
GC_DECLARE_ALLOCATOR(ArrayBuffer);
|
||||
|
||||
public:
|
||||
static ThrowCompletionOr<GC::Ref<ArrayBuffer>> create(Realm&, size_t);
|
||||
static GC::Ref<ArrayBuffer> create(Realm&, ByteBuffer);
|
||||
static GC::Ref<ArrayBuffer> create(Realm&, ByteBuffer*);
|
||||
static ThrowCompletionOr<GC::Ref<ArrayBuffer>> create(Realm&, size_t, DataBlock::Shared = DataBlock::Shared::No);
|
||||
static GC::Ref<ArrayBuffer> create(Realm&, ByteBuffer, DataBlock::Shared = DataBlock::Shared::No);
|
||||
static GC::Ref<ArrayBuffer> create(Realm&, ByteBuffer*, DataBlock::Shared = DataBlock::Shared::No);
|
||||
|
||||
virtual ~ArrayBuffer() override = default;
|
||||
|
||||
|
@ -132,8 +132,8 @@ public:
|
|||
Value get_modify_set_value(size_t byte_index, Value value, ReadWriteModifyFunction operation, bool is_little_endian = true);
|
||||
|
||||
private:
|
||||
ArrayBuffer(ByteBuffer buffer, Object& prototype);
|
||||
ArrayBuffer(ByteBuffer* buffer, Object& prototype);
|
||||
ArrayBuffer(ByteBuffer buffer, DataBlock::Shared, Object& prototype);
|
||||
ArrayBuffer(ByteBuffer* buffer, DataBlock::Shared, Object& prototype);
|
||||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue