| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #define DataView_h | 27 #define DataView_h |
| 28 | 28 |
| 29 #include "wtf/ArrayBufferView.h" | 29 #include "wtf/ArrayBufferView.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 class ExceptionState; | 33 class ExceptionState; |
| 34 | 34 |
| 35 class DataView final : public ArrayBufferView { | 35 class DataView final : public ArrayBufferView { |
| 36 public: | 36 public: |
| 37 static PassRefPtr<DataView> create(unsigned length); | |
| 38 static PassRefPtr<DataView> create(PassRefPtr<ArrayBuffer>, unsigned byteOff
set, unsigned byteLength); | 37 static PassRefPtr<DataView> create(PassRefPtr<ArrayBuffer>, unsigned byteOff
set, unsigned byteLength); |
| 39 | 38 |
| 40 virtual unsigned byteLength() const override { return m_byteLength; } | 39 virtual unsigned byteLength() const override { return m_byteLength; } |
| 41 virtual ViewType type() const override { return TypeDataView; } | 40 virtual ViewType type() const override { return TypeDataView; } |
| 42 | 41 |
| 43 int8_t getInt8(unsigned byteOffset, ExceptionState&); | |
| 44 uint8_t getUint8(unsigned byteOffset, ExceptionState&); | |
| 45 int16_t getInt16(unsigned byteOffset, ExceptionState& ec) { return getInt16(
byteOffset, false, ec); } | |
| 46 int16_t getInt16(unsigned byteOffset, bool littleEndian, ExceptionState&); | 42 int16_t getInt16(unsigned byteOffset, bool littleEndian, ExceptionState&); |
| 47 uint16_t getUint16(unsigned byteOffset, ExceptionState& ec) { return getUint
16(byteOffset, false, ec); } | |
| 48 uint16_t getUint16(unsigned byteOffset, bool littleEndian, ExceptionState&); | 43 uint16_t getUint16(unsigned byteOffset, bool littleEndian, ExceptionState&); |
| 49 int32_t getInt32(unsigned byteOffset, ExceptionState& ec) { return getInt32(
byteOffset, false, ec); } | |
| 50 int32_t getInt32(unsigned byteOffset, bool littleEndian, ExceptionState&); | 44 int32_t getInt32(unsigned byteOffset, bool littleEndian, ExceptionState&); |
| 51 uint32_t getUint32(unsigned byteOffset, ExceptionState& ec) { return getUint
32(byteOffset, false, ec); } | |
| 52 uint32_t getUint32(unsigned byteOffset, bool littleEndian, ExceptionState&); | 45 uint32_t getUint32(unsigned byteOffset, bool littleEndian, ExceptionState&); |
| 53 float getFloat32(unsigned byteOffset, ExceptionState& ec) { return getFloat3
2(byteOffset, false, ec); } | |
| 54 float getFloat32(unsigned byteOffset, bool littleEndian, ExceptionState&); | 46 float getFloat32(unsigned byteOffset, bool littleEndian, ExceptionState&); |
| 55 double getFloat64(unsigned byteOffset, ExceptionState& ec) { return getFloat
64(byteOffset, false, ec); } | |
| 56 double getFloat64(unsigned byteOffset, bool littleEndian, ExceptionState&); | 47 double getFloat64(unsigned byteOffset, bool littleEndian, ExceptionState&); |
| 57 | 48 |
| 58 void setInt8(unsigned byteOffset, int8_t value, ExceptionState&); | |
| 59 void setUint8(unsigned byteOffset, uint8_t value, ExceptionState&); | |
| 60 void setInt16(unsigned byteOffset, int16_t value, ExceptionState& ec) { setI
nt16(byteOffset, value, false, ec); } | |
| 61 void setInt16(unsigned byteOffset, int16_t value, bool littleEndian, Excepti
onState&); | 49 void setInt16(unsigned byteOffset, int16_t value, bool littleEndian, Excepti
onState&); |
| 62 void setUint16(unsigned byteOffset, uint16_t value, ExceptionState& ec) { se
tUint16(byteOffset, value, false, ec); } | |
| 63 void setUint16(unsigned byteOffset, uint16_t value, bool littleEndian, Excep
tionState&); | 50 void setUint16(unsigned byteOffset, uint16_t value, bool littleEndian, Excep
tionState&); |
| 64 void setInt32(unsigned byteOffset, int32_t value, ExceptionState& ec) { setI
nt32(byteOffset, value, false, ec); } | |
| 65 void setInt32(unsigned byteOffset, int32_t value, bool littleEndian, Excepti
onState&); | 51 void setInt32(unsigned byteOffset, int32_t value, bool littleEndian, Excepti
onState&); |
| 66 void setUint32(unsigned byteOffset, uint32_t value, ExceptionState& ec) { se
tUint32(byteOffset, value, false, ec); } | |
| 67 void setUint32(unsigned byteOffset, uint32_t value, bool littleEndian, Excep
tionState&); | 52 void setUint32(unsigned byteOffset, uint32_t value, bool littleEndian, Excep
tionState&); |
| 68 void setFloat32(unsigned byteOffset, float value, ExceptionState& ec) { setF
loat32(byteOffset, value, false, ec); } | |
| 69 void setFloat32(unsigned byteOffset, float value, bool littleEndian, Excepti
onState&); | 53 void setFloat32(unsigned byteOffset, float value, bool littleEndian, Excepti
onState&); |
| 70 void setFloat64(unsigned byteOffset, double value, ExceptionState& ec) { set
Float64(byteOffset, value, false, ec); } | |
| 71 void setFloat64(unsigned byteOffset, double value, bool littleEndian, Except
ionState&); | 54 void setFloat64(unsigned byteOffset, double value, bool littleEndian, Except
ionState&); |
| 72 | 55 |
| 73 protected: | 56 protected: |
| 74 virtual void neuter() override; | 57 virtual void neuter() override; |
| 75 | 58 |
| 76 private: | 59 private: |
| 77 DataView(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned byteLength); | 60 DataView(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned byteLength); |
| 78 | 61 |
| 79 template<typename T> | 62 template<typename T> |
| 80 bool beyondRange(unsigned byteOffset) const { return byteOffset >= m_byteLen
gth || byteOffset + sizeof(T) > m_byteLength; } | 63 bool beyondRange(unsigned byteOffset) const { return byteOffset >= m_byteLen
gth || byteOffset + sizeof(T) > m_byteLength; } |
| 81 | 64 |
| 82 template<typename T> | 65 template<typename T> |
| 83 T getData(unsigned byteOffset, bool littleEndian, ExceptionState&) const; | 66 T getData(unsigned byteOffset, bool littleEndian, ExceptionState&) const; |
| 84 | 67 |
| 85 template<typename T> | 68 template<typename T> |
| 86 void setData(unsigned byteOffset, T value, bool littleEndian, ExceptionState
&); | 69 void setData(unsigned byteOffset, T value, bool littleEndian, ExceptionState
&); |
| 87 | 70 |
| 88 unsigned m_byteLength; | 71 unsigned m_byteLength; |
| 89 }; | 72 }; |
| 90 | 73 |
| 91 } // namespace blink | 74 } // namespace blink |
| 92 | 75 |
| 93 #endif // DataView_h | 76 #endif // DataView_h |
| OLD | NEW |