OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 { | 278 { |
279 v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size()); | 279 v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size()); |
280 int index = 0; | 280 int index = 0; |
281 typename Vector<T, inlineCapacity>::const_iterator end = iterator.end(); | 281 typename Vector<T, inlineCapacity>::const_iterator end = iterator.end(); |
282 typedef V8ValueTraits<T> TraitsType; | 282 typedef V8ValueTraits<T> TraitsType; |
283 for (typename Vector<T, inlineCapacity>::const_iterator iter = iterator.
begin(); iter != end; ++iter) | 283 for (typename Vector<T, inlineCapacity>::const_iterator iter = iterator.
begin(); iter != end; ++iter) |
284 result->Set(v8::Integer::New(isolate, index++), TraitsType::arrayV8V
alue(*iter, isolate)); | 284 result->Set(v8::Integer::New(isolate, index++), TraitsType::arrayV8V
alue(*iter, isolate)); |
285 return result; | 285 return result; |
286 } | 286 } |
287 | 287 |
288 template<typename T, size_t inlineCapacity> | |
289 v8::Handle<v8::Value> v8Array(const HeapVector<T, inlineCapacity>& iterator,
v8::Isolate* isolate) | |
290 { | |
291 v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size()); | |
292 int index = 0; | |
293 typename HeapVector<T, inlineCapacity>::const_iterator end = iterator.en
d(); | |
294 typedef V8ValueTraits<T> TraitsType; | |
295 for (typename HeapVector<T, inlineCapacity>::const_iterator iter = itera
tor.begin(); iter != end; ++iter) | |
296 result->Set(v8::Integer::New(isolate, index++), TraitsType::arrayV8V
alue(*iter, isolate)); | |
297 return result; | |
298 } | |
299 | |
300 // Conversion flags, used in toIntXX/toUIntXX. | 288 // Conversion flags, used in toIntXX/toUIntXX. |
301 enum IntegerConversionConfiguration { | 289 enum IntegerConversionConfiguration { |
302 NormalConversion, | 290 NormalConversion, |
303 EnforceRange, | 291 EnforceRange, |
304 Clamp | 292 Clamp |
305 }; | 293 }; |
306 | 294 |
307 // Convert a value to a 8-bit signed integer. The conversion fails if the | 295 // Convert a value to a 8-bit signed integer. The conversion fails if the |
308 // value cannot be converted to a number or the range violated per WebIDL: | 296 // value cannot be converted to a number or the range violated per WebIDL: |
309 // http://www.w3.org/TR/WebIDL/#es-byte | 297 // http://www.w3.org/TR/WebIDL/#es-byte |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 m_isolate->ClearInterrupt(); | 709 m_isolate->ClearInterrupt(); |
722 } | 710 } |
723 | 711 |
724 private: | 712 private: |
725 v8::Isolate* m_isolate; | 713 v8::Isolate* m_isolate; |
726 }; | 714 }; |
727 | 715 |
728 } // namespace WebCore | 716 } // namespace WebCore |
729 | 717 |
730 #endif // V8Binding_h | 718 #endif // V8Binding_h |
OLD | NEW |