#ifndef Float32Array_h
#define Float32Array_h
#include "wtf/TypedArrayBase.h"
#include "wtf/MathExtras.h"
namespace WTF {
class Float32Array FINAL : public TypedArrayBase<float> {
public:
static inline PassRefPtr<Float32Array> create(unsigned length);
static inline PassRefPtr<Float32Array> create(const float* array, unsigned length);
static inline PassRefPtr<Float32Array> create(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length);
static inline PassRefPtr<Float32Array> createUninitialized(unsigned length);
using TypedArrayBase<float>::set;
void set(unsigned index, double value)
{
if (index >= TypedArrayBase<float>::m_length)
return;
TypedArrayBase<float>::data()[index] = static_cast<float>(value);
}
inline PassRefPtr<Float32Array> subarray(int start) const;
inline PassRefPtr<Float32Array> subarray(int start, int end) const;
virtual ViewType type() const OVERRIDE
{
return TypeFloat32;
}
private:
inline Float32Array(PassRefPtr<ArrayBuffer>,
unsigned byteOffset,
unsigned length);
friend class TypedArrayBase<float>;
};
PassRefPtr<Float32Array> Float32Array::create(unsigned length)
{
return TypedArrayBase<float>::create<Float32Array>(length);
}
PassRefPtr<Float32Array> Float32Array::create(const float* array, unsigned length)
{
return TypedArrayBase<float>::create<Float32Array>(array, length);
}
PassRefPtr<Float32Array> Float32Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
{
return TypedArrayBase<float>::create<Float32Array>(buffer, byteOffset, length);
}
PassRefPtr<Float32Array> Float32Array::createUninitialized(unsigned length)
{
return TypedArrayBase<float>::createUninitialized<Float32Array>(length);
}
Float32Array::Float32Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
: TypedArrayBase<float>(buffer, byteOffset, length)
{
}
PassRefPtr<Float32Array> Float32Array::subarray(int start) const
{
return subarray(start, length());
}
PassRefPtr<Float32Array> Float32Array::subarray(int start, int end) const
{
return subarrayImpl<Float32Array>(start, end);
}
}
using WTF::Float32Array;
#endif