| 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 "bindings/core/v8/ScriptWrappable.h" | 29 #include "bindings/core/v8/ScriptWrappable.h" |
| 30 #include "wtf/ArrayBufferView.h" | 30 #include "wtf/ArrayBufferView.h" |
| 31 #include "wtf/PassRefPtr.h" | 31 #include "wtf/PassRefPtr.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 class ExceptionState; | 35 class ExceptionState; |
| 36 | 36 |
| 37 class DataView FINAL : public ArrayBufferView, public ScriptWrappable { | 37 class DataView final : public ArrayBufferView, public ScriptWrappable { |
| 38 DEFINE_WRAPPERTYPEINFO(); | 38 DEFINE_WRAPPERTYPEINFO(); |
| 39 public: | 39 public: |
| 40 static PassRefPtr<DataView> create(unsigned length); | 40 static PassRefPtr<DataView> create(unsigned length); |
| 41 static PassRefPtr<DataView> create(PassRefPtr<ArrayBuffer>, unsigned byteOff
set, unsigned byteLength); | 41 static PassRefPtr<DataView> create(PassRefPtr<ArrayBuffer>, unsigned byteOff
set, unsigned byteLength); |
| 42 | 42 |
| 43 virtual unsigned byteLength() const OVERRIDE { return m_byteLength; } | 43 virtual unsigned byteLength() const override { return m_byteLength; } |
| 44 | 44 |
| 45 int8_t getInt8(unsigned byteOffset, ExceptionState&); | 45 int8_t getInt8(unsigned byteOffset, ExceptionState&); |
| 46 uint8_t getUint8(unsigned byteOffset, ExceptionState&); | 46 uint8_t getUint8(unsigned byteOffset, ExceptionState&); |
| 47 int16_t getInt16(unsigned byteOffset, ExceptionState& ec) { return getInt16(
byteOffset, false, ec); } | 47 int16_t getInt16(unsigned byteOffset, ExceptionState& ec) { return getInt16(
byteOffset, false, ec); } |
| 48 int16_t getInt16(unsigned byteOffset, bool littleEndian, ExceptionState&); | 48 int16_t getInt16(unsigned byteOffset, bool littleEndian, ExceptionState&); |
| 49 uint16_t getUint16(unsigned byteOffset, ExceptionState& ec) { return getUint
16(byteOffset, false, ec); } | 49 uint16_t getUint16(unsigned byteOffset, ExceptionState& ec) { return getUint
16(byteOffset, false, ec); } |
| 50 uint16_t getUint16(unsigned byteOffset, bool littleEndian, ExceptionState&); | 50 uint16_t getUint16(unsigned byteOffset, bool littleEndian, ExceptionState&); |
| 51 int32_t getInt32(unsigned byteOffset, ExceptionState& ec) { return getInt32(
byteOffset, false, ec); } | 51 int32_t getInt32(unsigned byteOffset, ExceptionState& ec) { return getInt32(
byteOffset, false, ec); } |
| 52 int32_t getInt32(unsigned byteOffset, bool littleEndian, ExceptionState&); | 52 int32_t getInt32(unsigned byteOffset, bool littleEndian, ExceptionState&); |
| 53 uint32_t getUint32(unsigned byteOffset, ExceptionState& ec) { return getUint
32(byteOffset, false, ec); } | 53 uint32_t getUint32(unsigned byteOffset, ExceptionState& ec) { return getUint
32(byteOffset, false, ec); } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 65 void setUint16(unsigned byteOffset, uint16_t value, bool littleEndian, Excep
tionState&); | 65 void setUint16(unsigned byteOffset, uint16_t value, bool littleEndian, Excep
tionState&); |
| 66 void setInt32(unsigned byteOffset, int32_t value, ExceptionState& ec) { setI
nt32(byteOffset, value, false, ec); } | 66 void setInt32(unsigned byteOffset, int32_t value, ExceptionState& ec) { setI
nt32(byteOffset, value, false, ec); } |
| 67 void setInt32(unsigned byteOffset, int32_t value, bool littleEndian, Excepti
onState&); | 67 void setInt32(unsigned byteOffset, int32_t value, bool littleEndian, Excepti
onState&); |
| 68 void setUint32(unsigned byteOffset, uint32_t value, ExceptionState& ec) { se
tUint32(byteOffset, value, false, ec); } | 68 void setUint32(unsigned byteOffset, uint32_t value, ExceptionState& ec) { se
tUint32(byteOffset, value, false, ec); } |
| 69 void setUint32(unsigned byteOffset, uint32_t value, bool littleEndian, Excep
tionState&); | 69 void setUint32(unsigned byteOffset, uint32_t value, bool littleEndian, Excep
tionState&); |
| 70 void setFloat32(unsigned byteOffset, float value, ExceptionState& ec) { setF
loat32(byteOffset, value, false, ec); } | 70 void setFloat32(unsigned byteOffset, float value, ExceptionState& ec) { setF
loat32(byteOffset, value, false, ec); } |
| 71 void setFloat32(unsigned byteOffset, float value, bool littleEndian, Excepti
onState&); | 71 void setFloat32(unsigned byteOffset, float value, bool littleEndian, Excepti
onState&); |
| 72 void setFloat64(unsigned byteOffset, double value, ExceptionState& ec) { set
Float64(byteOffset, value, false, ec); } | 72 void setFloat64(unsigned byteOffset, double value, ExceptionState& ec) { set
Float64(byteOffset, value, false, ec); } |
| 73 void setFloat64(unsigned byteOffset, double value, bool littleEndian, Except
ionState&); | 73 void setFloat64(unsigned byteOffset, double value, bool littleEndian, Except
ionState&); |
| 74 | 74 |
| 75 virtual ViewType type() const OVERRIDE | 75 virtual ViewType type() const override |
| 76 { | 76 { |
| 77 return TypeDataView; | 77 return TypeDataView; |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual v8::Handle<v8::Object> wrap(v8::Handle<v8::Object> creationContext,
v8::Isolate*) OVERRIDE; | 80 virtual v8::Handle<v8::Object> wrap(v8::Handle<v8::Object> creationContext,
v8::Isolate*) override; |
| 81 | 81 |
| 82 protected: | 82 protected: |
| 83 virtual void neuter() OVERRIDE; | 83 virtual void neuter() override; |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 DataView(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned byteLength); | 86 DataView(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned byteLength); |
| 87 | 87 |
| 88 template<typename T> | 88 template<typename T> |
| 89 inline bool beyondRange(unsigned byteOffset) const { return byteOffset >= m_
byteLength || byteOffset + sizeof(T) > m_byteLength; } | 89 inline bool beyondRange(unsigned byteOffset) const { return byteOffset >= m_
byteLength || byteOffset + sizeof(T) > m_byteLength; } |
| 90 | 90 |
| 91 template<typename T> | 91 template<typename T> |
| 92 T getData(unsigned byteOffset, bool littleEndian, ExceptionState&) const; | 92 T getData(unsigned byteOffset, bool littleEndian, ExceptionState&) const; |
| 93 | 93 |
| 94 template<typename T> | 94 template<typename T> |
| 95 void setData(unsigned byteOffset, T value, bool littleEndian, ExceptionState
&); | 95 void setData(unsigned byteOffset, T value, bool littleEndian, ExceptionState
&); |
| 96 | 96 |
| 97 unsigned m_byteLength; | 97 unsigned m_byteLength; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace blink | 100 } // namespace blink |
| 101 | 101 |
| 102 #endif // DataView_h | 102 #endif // DataView_h |
| OLD | NEW |