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 |
288 // Conversion flags, used in toIntXX/toUIntXX. | 300 // Conversion flags, used in toIntXX/toUIntXX. |
289 enum IntegerConversionConfiguration { | 301 enum IntegerConversionConfiguration { |
290 NormalConversion, | 302 NormalConversion, |
291 EnforceRange, | 303 EnforceRange, |
292 Clamp | 304 Clamp |
293 }; | 305 }; |
294 | 306 |
295 // Convert a value to a 8-bit signed integer. The conversion fails if the | 307 // Convert a value to a 8-bit signed integer. The conversion fails if the |
296 // value cannot be converted to a number or the range violated per WebIDL: | 308 // value cannot be converted to a number or the range violated per WebIDL: |
297 // http://www.w3.org/TR/WebIDL/#es-byte | 309 // http://www.w3.org/TR/WebIDL/#es-byte |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 m_isolate->ClearInterrupt(); | 721 m_isolate->ClearInterrupt(); |
710 } | 722 } |
711 | 723 |
712 private: | 724 private: |
713 v8::Isolate* m_isolate; | 725 v8::Isolate* m_isolate; |
714 }; | 726 }; |
715 | 727 |
716 } // namespace WebCore | 728 } // namespace WebCore |
717 | 729 |
718 #endif // V8Binding_h | 730 #endif // V8Binding_h |
OLD | NEW |