Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: Source/bindings/core/v8/V8Binding.h

Issue 400493005: Make vector conversion more general in V8Bindings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: narrower Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8BindingTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/V8Binding.h
diff --git a/Source/bindings/core/v8/V8Binding.h b/Source/bindings/core/v8/V8Binding.h
index f26a98b1040fda2bba60d2269d511db960e86900..14cac2abf7a8479a83b545b4f787cd7f298cb3ff 100644
--- a/Source/bindings/core/v8/V8Binding.h
+++ b/Source/bindings/core/v8/V8Binding.h
@@ -237,22 +237,6 @@ struct V8ValueTraits {
}
};
-template <typename T, size_t inlineCapacity, typename Allocator>
-struct V8ValueTraits<WTF::Vector<T, inlineCapacity, Allocator> > {
- static v8::Handle<v8::Value> toV8Value(const Vector<T, inlineCapacity, Allocator>& value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
- {
- return v8ArrayNoInline(value, creationContext, isolate);
- }
-};
-
-template <typename T, size_t inlineCapacity>
-struct V8ValueTraits<HeapVector<T, inlineCapacity> > {
- static v8::Handle<v8::Value> toV8Value(const HeapVector<T, inlineCapacity>& value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
- {
- return v8ArrayNoInline(value, creationContext, isolate);
- }
-};
-
template<>
struct V8ValueTraits<String> {
static inline v8::Handle<v8::Value> toV8Value(const String& value, v8::Handle<v8::Object>, v8::Isolate* isolate)
@@ -418,6 +402,14 @@ v8::Handle<v8::Value> v8Array(const Vector<T, inlineCapacity>& iterator, v8::Han
return result;
}
+template <typename T, size_t inlineCapacity, typename Allocator>
+struct V8ValueTraits<WTF::Vector<T, inlineCapacity, Allocator> > {
yhirano 2014/07/23 01:51:52 Can you tell me why you move toV8Value functions?
gavinp 2014/07/23 01:57:24 Type deduction across namespaces for function temp
+ static v8::Handle<v8::Value> toV8Value(const Vector<T, inlineCapacity, Allocator>& value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+ {
+ return v8Array(value, creationContext, isolate);
+ }
+};
+
template<typename T, size_t inlineCapacity>
v8::Handle<v8::Value> v8Array(const HeapVector<T, inlineCapacity>& iterator, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
@@ -430,27 +422,13 @@ v8::Handle<v8::Value> v8Array(const HeapVector<T, inlineCapacity>& iterator, v8:
return result;
}
-template<typename T, size_t inlineCapacity>
-v8::Handle<v8::Value> v8ArrayNoInline(const Vector<T, inlineCapacity>& iterator, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
-{
- v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size());
- int index = 0;
- typename Vector<T, inlineCapacity>::const_iterator end = iterator.end();
- for (typename Vector<T, inlineCapacity>::const_iterator iter = iterator.begin(); iter != end; ++iter)
- result->Set(v8::Integer::New(isolate, index++), toV8NoInline(WTF::getPtr(*iter), creationContext, isolate));
- return result;
-}
-
-template<typename T, size_t inlineCapacity>
-v8::Handle<v8::Value> v8ArrayNoInline(const HeapVector<T, inlineCapacity>& iterator, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
-{
- v8::Local<v8::Array> result = v8::Array::New(isolate, iterator.size());
- int index = 0;
- typename HeapVector<T, inlineCapacity>::const_iterator end = iterator.end();
- for (typename HeapVector<T, inlineCapacity>::const_iterator iter = iterator.begin(); iter != end; ++iter)
- result->Set(v8::Integer::New(isolate, index++), toV8NoInline(WTF::getPtr(*iter), creationContext, isolate));
- return result;
-}
+template <typename T, size_t inlineCapacity>
+struct V8ValueTraits<HeapVector<T, inlineCapacity> > {
+ static v8::Handle<v8::Value> toV8Value(const HeapVector<T, inlineCapacity>& value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+ {
+ return v8Array(value, creationContext, isolate);
+ }
+};
// Conversion flags, used in toIntXX/toUIntXX.
enum IntegerConversionConfiguration {
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8BindingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698