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

Side by Side 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: finished self review, PTAL 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Binding.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 template <typename T> 230 template <typename T>
231 struct V8ValueTraits { 231 struct V8ValueTraits {
232 static v8::Handle<v8::Value> toV8Value(const T& value, v8::Handle<v8::Object > creationContext, v8::Isolate* isolate) 232 static v8::Handle<v8::Value> toV8Value(const T& value, v8::Handle<v8::Object > creationContext, v8::Isolate* isolate)
233 { 233 {
234 if (!WTF::getPtr(value)) 234 if (!WTF::getPtr(value))
235 return v8::Null(isolate); 235 return v8::Null(isolate);
236 return toV8NoInline(WTF::getPtr(value), creationContext, isolate); 236 return toV8NoInline(WTF::getPtr(value), creationContext, isolate);
237 } 237 }
238 }; 238 };
239 239
240 template<typename T, size_t inlineCapacity>
241 v8::Handle<v8::Value> v8ArrayNoInline(const Vector<T, inlineCapacity>& iterator, v8::Handle<v8::Object> creationContext, v8::Isolate*);
gavinp 2014/07/20 04:15:18 These two forward declarations are required to mak
242
240 template <typename T, size_t inlineCapacity, typename Allocator> 243 template <typename T, size_t inlineCapacity, typename Allocator>
241 struct V8ValueTraits<WTF::Vector<T, inlineCapacity, Allocator> > { 244 struct V8ValueTraits<WTF::Vector<T, inlineCapacity, Allocator> > {
242 static v8::Handle<v8::Value> toV8Value(const Vector<T, inlineCapacity, Alloc ator>& value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 245 static v8::Handle<v8::Value> toV8Value(const Vector<T, inlineCapacity, Alloc ator>& value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
243 { 246 {
244 return v8ArrayNoInline(value, creationContext, isolate); 247 return v8ArrayNoInline(value, creationContext, isolate);
245 } 248 }
246 }; 249 };
247 250
251 template<typename T, size_t inlineCapacity>
252 v8::Handle<v8::Value> v8ArrayNoInline(const HeapVector<T, inlineCapacity>& itera tor, v8::Handle<v8::Object> creationContext, v8::Isolate*);
253
248 template <typename T, size_t inlineCapacity> 254 template <typename T, size_t inlineCapacity>
249 struct V8ValueTraits<HeapVector<T, inlineCapacity> > { 255 struct V8ValueTraits<HeapVector<T, inlineCapacity> > {
250 static v8::Handle<v8::Value> toV8Value(const HeapVector<T, inlineCapacity>& value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 256 static v8::Handle<v8::Value> toV8Value(const HeapVector<T, inlineCapacity>& value, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
251 { 257 {
252 return v8ArrayNoInline(value, creationContext, isolate); 258 return v8ArrayNoInline(value, creationContext, isolate);
253 } 259 }
254 }; 260 };
255 261
262 // These explicit specializations allow basic data types to be converted via V8V alueTraits<>::toV8Value(). Where sensible, each data type
263 // should also have an explicit specialization of toV8NoInline<>() in V8Binding. cpp, so that vectors of the same type can also be converted.
haraken 2014/07/20 04:50:46 Just help me understand: Why do we need to have ex
gavinp 2014/07/20 05:11:16 I do not know; I am very new in this coding area.
haraken 2014/07/20 05:16:35 I think we can ask yhirano@ or tasak@ :) The toV8
256 template<> 264 template<>
257 struct V8ValueTraits<String> { 265 struct V8ValueTraits<String> {
258 static inline v8::Handle<v8::Value> toV8Value(const String& value, v8::Handl e<v8::Object>, v8::Isolate* isolate) 266 static inline v8::Handle<v8::Value> toV8Value(const String& value, v8::Handl e<v8::Object>, v8::Isolate* isolate)
259 { 267 {
260 return v8String(isolate, value); 268 return v8String(isolate, value);
261 } 269 }
262 }; 270 };
263 271
264 template<> 272 template<>
265 struct V8ValueTraits<AtomicString> { 273 struct V8ValueTraits<AtomicString> {
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 m_block.Reset(); 1001 m_block.Reset();
994 } 1002 }
995 1003
996 private: 1004 private:
997 v8::TryCatch& m_block; 1005 v8::TryCatch& m_block;
998 }; 1006 };
999 1007
1000 } // namespace WebCore 1008 } // namespace WebCore
1001 1009
1002 #endif // V8Binding_h 1010 #endif // V8Binding_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Binding.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698