diff options
author | Linus Groh <mail@linusgroh.de> | 2021-12-13 22:05:42 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-14 09:01:06 +0100 |
commit | 841bd680faa1cd79f0f0c41effdfe4819aff41ed (patch) | |
tree | 4d4cdf94e661120bb98d4806fb288175db9f52e1 /Userland/Libraries/LibJS/Runtime | |
parent | 615be9eb7ca88b20a13021cdf3eaf058c9059599 (diff) | |
download | serenity-841bd680faa1cd79f0f0c41effdfe4819aff41ed.zip |
LibJS: Add ArrayBuffer::create() for ByteBuffer passed by value
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ArrayBuffer.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp index 6b57a80f5a..d727813183 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp @@ -20,6 +20,11 @@ ArrayBuffer* ArrayBuffer::create(GlobalObject& global_object, size_t byte_length return global_object.heap().allocate<ArrayBuffer>(global_object, buffer.release_value(), *global_object.array_buffer_prototype()); } +ArrayBuffer* ArrayBuffer::create(GlobalObject& global_object, ByteBuffer buffer) +{ + return global_object.heap().allocate<ArrayBuffer>(global_object, move(buffer), *global_object.array_buffer_prototype()); +} + ArrayBuffer* ArrayBuffer::create(GlobalObject& global_object, ByteBuffer* buffer) { return global_object.heap().allocate<ArrayBuffer>(global_object, buffer, *global_object.array_buffer_prototype()); diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h index ec438d319e..ec4662509e 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.h @@ -26,6 +26,7 @@ class ArrayBuffer : public Object { public: static ArrayBuffer* create(GlobalObject&, size_t); + static ArrayBuffer* create(GlobalObject&, ByteBuffer); static ArrayBuffer* create(GlobalObject&, ByteBuffer*); ArrayBuffer(ByteBuffer buffer, Object& prototype); |