2020-12-02 20:49:31 +00:00
|
|
|
/*
|
2021-04-22 22:51:19 +02:00
|
|
|
* Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
|
2020-12-02 20:49:31 +00:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-12-02 20:49:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/ArrayBuffer.h>
|
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
ArrayBuffer* ArrayBuffer::create(GlobalObject& global_object, size_t byte_size)
|
|
|
|
{
|
|
|
|
return global_object.heap().allocate<ArrayBuffer>(global_object, byte_size, *global_object.array_buffer_prototype());
|
|
|
|
}
|
|
|
|
|
2021-04-02 21:31:23 +01:00
|
|
|
ArrayBuffer* ArrayBuffer::create(GlobalObject& global_object, ByteBuffer& buffer)
|
|
|
|
{
|
|
|
|
return global_object.heap().allocate<ArrayBuffer>(global_object, buffer, *global_object.array_buffer_prototype());
|
|
|
|
}
|
|
|
|
|
2021-05-17 21:39:31 +04:30
|
|
|
ArrayBuffer* ArrayBuffer::create(GlobalObject& global_object, ByteBuffer* buffer)
|
|
|
|
{
|
|
|
|
return global_object.heap().allocate<ArrayBuffer>(global_object, buffer, *global_object.array_buffer_prototype());
|
|
|
|
}
|
|
|
|
|
2020-12-02 20:49:31 +00:00
|
|
|
ArrayBuffer::ArrayBuffer(size_t byte_size, Object& prototype)
|
|
|
|
: Object(prototype)
|
|
|
|
, m_buffer(ByteBuffer::create_zeroed(byte_size))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-04-02 21:31:23 +01:00
|
|
|
ArrayBuffer::ArrayBuffer(ByteBuffer& buffer, Object& prototype)
|
|
|
|
: Object(prototype)
|
|
|
|
, m_buffer(buffer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-17 21:39:31 +04:30
|
|
|
ArrayBuffer::ArrayBuffer(ByteBuffer* buffer, Object& prototype)
|
|
|
|
: Object(prototype)
|
|
|
|
, m_buffer(buffer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-12-02 20:49:31 +00:00
|
|
|
ArrayBuffer::~ArrayBuffer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|