| 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 17 matching lines...) Expand all Loading... |
| 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 public: | 39 public: |
| 39 static PassRefPtr<DataView> create(unsigned length); | 40 static PassRefPtr<DataView> create(unsigned length); |
| 40 static PassRefPtr<DataView> create(PassRefPtr<ArrayBuffer>, unsigned byteOff
set, unsigned byteLength); | 41 static PassRefPtr<DataView> create(PassRefPtr<ArrayBuffer>, unsigned byteOff
set, unsigned byteLength); |
| 41 | 42 |
| 42 virtual unsigned byteLength() const OVERRIDE { return m_byteLength; } | 43 virtual unsigned byteLength() const OVERRIDE { return m_byteLength; } |
| 43 | 44 |
| 44 int8_t getInt8(unsigned byteOffset, ExceptionState&); | 45 int8_t getInt8(unsigned byteOffset, ExceptionState&); |
| 45 uint8_t getUint8(unsigned byteOffset, ExceptionState&); | 46 uint8_t getUint8(unsigned byteOffset, ExceptionState&); |
| 46 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); } |
| 47 int16_t getInt16(unsigned byteOffset, bool littleEndian, ExceptionState&); | 48 int16_t getInt16(unsigned byteOffset, bool littleEndian, ExceptionState&); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 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); } |
| 70 void setFloat32(unsigned byteOffset, float value, bool littleEndian, Excepti
onState&); | 71 void setFloat32(unsigned byteOffset, float value, bool littleEndian, Excepti
onState&); |
| 71 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); } |
| 72 void setFloat64(unsigned byteOffset, double value, bool littleEndian, Except
ionState&); | 73 void setFloat64(unsigned byteOffset, double value, bool littleEndian, Except
ionState&); |
| 73 | 74 |
| 74 virtual ViewType type() const OVERRIDE | 75 virtual ViewType type() const OVERRIDE |
| 75 { | 76 { |
| 76 return TypeDataView; | 77 return TypeDataView; |
| 77 } | 78 } |
| 78 | 79 |
| 80 virtual v8::Handle<v8::Object> wrap(v8::Handle<v8::Object> creationContext,
v8::Isolate*) OVERRIDE; |
| 81 |
| 79 protected: | 82 protected: |
| 80 virtual void neuter() OVERRIDE; | 83 virtual void neuter() OVERRIDE; |
| 81 | 84 |
| 82 private: | 85 private: |
| 83 DataView(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned byteLength); | 86 DataView(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned byteLength); |
| 84 | 87 |
| 85 template<typename T> | 88 template<typename T> |
| 86 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; } |
| 87 | 90 |
| 88 template<typename T> | 91 template<typename T> |
| 89 T getData(unsigned byteOffset, bool littleEndian, ExceptionState&) const; | 92 T getData(unsigned byteOffset, bool littleEndian, ExceptionState&) const; |
| 90 | 93 |
| 91 template<typename T> | 94 template<typename T> |
| 92 void setData(unsigned byteOffset, T value, bool littleEndian, ExceptionState
&); | 95 void setData(unsigned byteOffset, T value, bool littleEndian, ExceptionState
&); |
| 93 | 96 |
| 94 unsigned m_byteLength; | 97 unsigned m_byteLength; |
| 95 }; | 98 }; |
| 96 | 99 |
| 97 | |
| 98 } // namespace blink | 100 } // namespace blink |
| 99 | 101 |
| 100 #endif // DataView_h | 102 #endif // DataView_h |
| OLD | NEW |