Lines 28-33
Link Here
|
28 |
#include "JSArrayBufferView.h" |
28 |
#include "JSArrayBufferView.h" |
29 |
#include "ThrowScope.h" |
29 |
#include "ThrowScope.h" |
30 |
#include "ToNativeFromValue.h" |
30 |
#include "ToNativeFromValue.h" |
|
|
31 |
#include <wtf/FlipBytes.h> |
31 |
|
32 |
|
32 |
namespace JSC { |
33 |
namespace JSC { |
33 |
|
34 |
|
Lines 146-152
public:
Link Here
|
146 |
|
147 |
|
147 |
JSValue getIndexQuickly(unsigned i) const |
148 |
JSValue getIndexQuickly(unsigned i) const |
148 |
{ |
149 |
{ |
|
|
150 |
#if CPU(BIG_ENDIAN) |
151 |
switch (Adaptor::typeValue) { |
152 |
case TypeFloat32: |
153 |
case TypeFloat64: |
154 |
return Adaptor::toJSValue(nullptr, getIndexQuicklyAsNativeValue(i)); |
155 |
default: |
156 |
// typed array views are commonly expected to be little endian views of the underlying data |
157 |
return Adaptor::toJSValue(nullptr, flipBytes(getIndexQuicklyAsNativeValue(i))); |
158 |
} |
159 |
#else |
149 |
return Adaptor::toJSValue(nullptr, getIndexQuicklyAsNativeValue(i)); |
160 |
return Adaptor::toJSValue(nullptr, getIndexQuicklyAsNativeValue(i)); |
|
|
161 |
#endif |
150 |
} |
162 |
} |
151 |
|
163 |
|
152 |
void setIndexQuicklyToNativeValue(unsigned i, typename Adaptor::Type value) |
164 |
void setIndexQuicklyToNativeValue(unsigned i, typename Adaptor::Type value) |
Lines 158-164
public:
Link Here
|
158 |
void setIndexQuickly(unsigned i, JSValue value) |
170 |
void setIndexQuickly(unsigned i, JSValue value) |
159 |
{ |
171 |
{ |
160 |
ASSERT(!value.isObject()); |
172 |
ASSERT(!value.isObject()); |
|
|
173 |
#if CPU(BIG_ENDIAN) |
174 |
switch (Adaptor::typeValue) { |
175 |
case TypeFloat32: |
176 |
case TypeFloat64: |
177 |
setIndexQuicklyToNativeValue(i, toNativeFromValue<Adaptor>(value)); |
178 |
break; |
179 |
default: |
180 |
// typed array views are commonly expected to be little endian views of the underlying data |
181 |
setIndexQuicklyToNativeValue(i, flipBytes(toNativeFromValue<Adaptor>(value))); |
182 |
break; |
183 |
} |
184 |
#else |
161 |
setIndexQuicklyToNativeValue(i, toNativeFromValue<Adaptor>(value)); |
185 |
setIndexQuicklyToNativeValue(i, toNativeFromValue<Adaptor>(value)); |
|
|
186 |
#endif |
162 |
} |
187 |
} |
163 |
|
188 |
|
164 |
bool setIndex(JSGlobalObject* globalObject, unsigned i, JSValue jsValue) |
189 |
bool setIndex(JSGlobalObject* globalObject, unsigned i, JSValue jsValue) |
Lines 172-184
public:
Link Here
|
172 |
if (isDetached() || i >= m_length) |
197 |
if (isDetached() || i >= m_length) |
173 |
return false; |
198 |
return false; |
174 |
|
199 |
|
|
|
200 |
#if CPU(BIG_ENDIAN) |
201 |
switch (Adaptor::typeValue) { |
202 |
case TypeFloat32: |
203 |
case TypeFloat64: |
204 |
setIndexQuicklyToNativeValue(i, value); |
205 |
break; |
206 |
default: |
207 |
// typed array views are commonly expected to be little endian views of the underlying data |
208 |
setIndexQuicklyToNativeValue(i, flipBytes(value)); |
209 |
break; |
210 |
} |
211 |
#else |
175 |
setIndexQuicklyToNativeValue(i, value); |
212 |
setIndexQuicklyToNativeValue(i, value); |
|
|
213 |
#endif |
176 |
return true; |
214 |
return true; |
177 |
} |
215 |
} |
178 |
|
216 |
|
179 |
static ElementType toAdaptorNativeFromValue(JSGlobalObject* globalObject, JSValue jsValue) { return toNativeFromValue<Adaptor>(globalObject, jsValue); } |
217 |
static ElementType toAdaptorNativeFromValue(JSGlobalObject* globalObject, JSValue jsValue) |
|
|
218 |
{ |
219 |
#if CPU(BIG_ENDIAN) |
220 |
switch (Adaptor::typeValue) { |
221 |
case TypeFloat32: |
222 |
case TypeFloat64: |
223 |
return toNativeFromValue<Adaptor>(globalObject, jsValue); |
224 |
default: |
225 |
// typed array views are commonly expected to be little endian views of the underlying data |
226 |
return flipBytes(toNativeFromValue<Adaptor>(globalObject, jsValue)); |
227 |
} |
228 |
#else |
229 |
return toNativeFromValue<Adaptor>(globalObject, jsValue); |
230 |
#endif |
231 |
} |
180 |
|
232 |
|
181 |
static Optional<ElementType> toAdaptorNativeFromValueWithoutCoercion(JSValue jsValue) { return toNativeFromValueWithoutCoercion<Adaptor>(jsValue); } |
233 |
static Optional<ElementType> toAdaptorNativeFromValueWithoutCoercion(JSValue jsValue) |
|
|
234 |
{ |
235 |
#if CPU(BIG_ENDIAN) |
236 |
switch (Adaptor::typeValue) { |
237 |
case TypeFloat32: |
238 |
case TypeFloat64: |
239 |
return toNativeFromValueWithoutCoercion<Adaptor>(jsValue); |
240 |
default: |
241 |
// typed array views are commonly expected to be little endian views of the underlying data |
242 |
return flipBytes(toNativeFromValueWithoutCoercion<Adaptor>(jsValue)); |
243 |
} |
244 |
#else |
245 |
return toNativeFromValueWithoutCoercion<Adaptor>(jsValue); |
246 |
#endif |
247 |
} |
182 |
|
248 |
|
183 |
void sort() |
249 |
void sort() |
184 |
{ |
250 |
{ |