| 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 } | 389 } |
| 390 | 390 |
| 391 template <typename T, size_t inlineCapacity, typename Allocator> | 391 template <typename T, size_t inlineCapacity, typename Allocator> |
| 392 struct V8ValueTraits<WTF::Vector<T, inlineCapacity, Allocator> > { | 392 struct V8ValueTraits<WTF::Vector<T, inlineCapacity, Allocator> > { |
| 393 static v8::Handle<v8::Value> toV8Value(const Vector<T, inlineCapacity, Alloc
ator>& value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 393 static v8::Handle<v8::Value> toV8Value(const Vector<T, inlineCapacity, Alloc
ator>& value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 394 { | 394 { |
| 395 return v8Array(value, creationContext, isolate); | 395 return v8Array(value, creationContext, isolate); |
| 396 } | 396 } |
| 397 }; | 397 }; |
| 398 | 398 |
| 399 template<typename T, size_t inlineCapacity> | |
| 400 v8::Handle<v8::Value> v8Array(const HeapVector<T, inlineCapacity>& iterator, v8:
:Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
| 401 { | |
| 402 v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size()); | |
| 403 int index = 0; | |
| 404 typename HeapVector<T, inlineCapacity>::const_iterator end = iterator.end(); | |
| 405 typedef V8ValueTraits<T> TraitsType; | |
| 406 for (typename HeapVector<T, inlineCapacity>::const_iterator iter = iterator.
begin(); iter != end; ++iter) | |
| 407 result->Set(v8::Integer::New(isolate, index++), TraitsType::toV8Value(*i
ter, creationContext, isolate)); | |
| 408 return result; | |
| 409 } | |
| 410 | |
| 411 template <typename T, size_t inlineCapacity> | 399 template <typename T, size_t inlineCapacity> |
| 412 struct V8ValueTraits<HeapVector<T, inlineCapacity> > { | 400 struct V8ValueTraits<Vector<T, inlineCapacity> > { |
| 413 static v8::Handle<v8::Value> toV8Value(const HeapVector<T, inlineCapacity>&
value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 401 static v8::Handle<v8::Value> toV8Value(const Vector<T, inlineCapacity>& valu
e, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 414 { | 402 { |
| 415 return v8Array(value, creationContext, isolate); | 403 return v8Array(value, creationContext, isolate); |
| 416 } | 404 } |
| 417 }; | 405 }; |
| 418 | 406 |
| 419 // Conversion flags, used in toIntXX/toUIntXX. | 407 // Conversion flags, used in toIntXX/toUIntXX. |
| 420 enum IntegerConversionConfiguration { | 408 enum IntegerConversionConfiguration { |
| 421 NormalConversion, | 409 NormalConversion, |
| 422 EnforceRange, | 410 EnforceRange, |
| 423 Clamp | 411 Clamp |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 m_block.ReThrow(); | 758 m_block.ReThrow(); |
| 771 } | 759 } |
| 772 | 760 |
| 773 private: | 761 private: |
| 774 v8::TryCatch& m_block; | 762 v8::TryCatch& m_block; |
| 775 }; | 763 }; |
| 776 | 764 |
| 777 } // namespace blink | 765 } // namespace blink |
| 778 | 766 |
| 779 #endif // V8Binding_h | 767 #endif // V8Binding_h |
| OLD | NEW |