Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ToV8_h | 5 #ifndef ToV8_h |
| 6 #define ToV8_h | 6 #define ToV8_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/DOMDataStore.h" | 8 #include "bindings/core/v8/DOMDataStore.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
| 10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 array->Set(v8::Integer::New(isolate, index++), toV8(*iter, creationConte xt, isolate)); | 203 array->Set(v8::Integer::New(isolate, index++), toV8(*iter, creationConte xt, isolate)); |
| 204 return array; | 204 return array; |
| 205 } | 205 } |
| 206 | 206 |
| 207 template<typename T, size_t inlineCapacity> | 207 template<typename T, size_t inlineCapacity> |
| 208 inline v8::Handle<v8::Value> toV8(const Vector<T, inlineCapacity>& value, v8::Ha ndle<v8::Object> creationContext, v8::Isolate* isolate) | 208 inline v8::Handle<v8::Value> toV8(const Vector<T, inlineCapacity>& value, v8::Ha ndle<v8::Object> creationContext, v8::Isolate* isolate) |
| 209 { | 209 { |
| 210 return toV8SequenceInternal(value, creationContext, isolate); | 210 return toV8SequenceInternal(value, creationContext, isolate); |
| 211 } | 211 } |
| 212 | 212 |
| 213 template<typename T> | |
| 214 inline v8::Handle<v8::Value> toV8(const Vector<std::pair<String, T>>& value, v8: :Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
|
Yuki
2015/03/04 14:11:04
Since both of toV8(Vector<T>) and toV8(HeapVector<
| |
| 215 { | |
| 216 v8::Local<v8::Object> object = v8::Object::New(isolate); | |
| 217 for (unsigned i = 0; i < value.size(); ++i) | |
| 218 object->Set(v8String(isolate, value[i].first), value[i].second); | |
|
Jens Widell
2015/03/04 13:53:52
By passing value[i].second directly to v8::Object:
vivekg
2015/03/04 13:57:19
Thanks Jens, I did the same thing initially.
Thou
Jens Widell
2015/03/04 14:03:54
It would certainly be wrong to include modules/v8/
Yuki
2015/03/04 14:11:04
Please use
toV8(value[i].second, creationContext
| |
| 219 return object; | |
| 220 } | |
| 221 | |
| 213 template<typename T, size_t inlineCapacity> | 222 template<typename T, size_t inlineCapacity> |
| 214 inline v8::Handle<v8::Value> toV8(const HeapVector<T, inlineCapacity>& value, v8 ::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 223 inline v8::Handle<v8::Value> toV8(const HeapVector<T, inlineCapacity>& value, v8 ::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 215 { | 224 { |
| 216 return toV8SequenceInternal(value, creationContext, isolate); | 225 return toV8SequenceInternal(value, creationContext, isolate); |
| 217 } | 226 } |
| 218 | 227 |
| 219 } // namespace blink | 228 } // namespace blink |
| 220 | 229 |
| 221 #endif // ToV8_h | 230 #endif // ToV8_h |
| OLD | NEW |