1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "wtf/ArrayPiece.h"
8 #include "wtf/ArrayBuffer.h"
9 #include "wtf/ArrayBufferView.h"
10 #include "wtf/Assertions.h"
14 ArrayPiece::ArrayPiece()
19 ArrayPiece::ArrayPiece(void* data
, unsigned byteLength
)
21 initWithData(data
, byteLength
);
24 ArrayPiece::ArrayPiece(ArrayBuffer
* buffer
)
27 initWithData(buffer
->data(), buffer
->byteLength());
33 ArrayPiece::ArrayPiece(ArrayBufferView
* buffer
)
36 initWithData(buffer
->baseAddress(), buffer
->byteLength());
42 bool ArrayPiece::isNull() const
47 void* ArrayPiece::data() const
53 unsigned char* ArrayPiece::bytes() const
55 return static_cast<unsigned char*>(data());
58 unsigned ArrayPiece::byteLength() const
64 void ArrayPiece::initWithData(void* data
, unsigned byteLength
)
66 m_byteLength
= byteLength
;
71 void ArrayPiece::initNull()