| 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 // ToV8() provides C++ -> V8 conversion. Note that ToV8() can return an empty | 8 // ToV8() provides C++ -> V8 conversion. Note that ToV8() can return an empty |
| 9 // handle. Call sites must check IsEmpty() before using return value. | 9 // handle. Call sites must check IsEmpty() before using return value. |
| 10 | 10 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 return toV8SequenceInternal(value, creationContext, isolate); | 224 return toV8SequenceInternal(value, creationContext, isolate); |
| 225 } | 225 } |
| 226 | 226 |
| 227 template <typename T, size_t inlineCapacity> | 227 template <typename T, size_t inlineCapacity> |
| 228 inline v8::Local<v8::Value> ToV8(const HeapVector<T, inlineCapacity>& value, | 228 inline v8::Local<v8::Value> ToV8(const HeapVector<T, inlineCapacity>& value, |
| 229 v8::Local<v8::Object> creationContext, | 229 v8::Local<v8::Object> creationContext, |
| 230 v8::Isolate* isolate) { | 230 v8::Isolate* isolate) { |
| 231 return toV8SequenceInternal(value, creationContext, isolate); | 231 return toV8SequenceInternal(value, creationContext, isolate); |
| 232 } | 232 } |
| 233 | 233 |
| 234 // The following two overloads are also used to convert record<K,V> IDL types |
| 235 // back into ECMAScript Objects. |
| 234 template <typename T> | 236 template <typename T> |
| 235 inline v8::Local<v8::Value> ToV8(const Vector<std::pair<String, T>>& value, | 237 inline v8::Local<v8::Value> ToV8(const Vector<std::pair<String, T>>& value, |
| 236 v8::Local<v8::Object> creationContext, | 238 v8::Local<v8::Object> creationContext, |
| 237 v8::Isolate* isolate) { | 239 v8::Isolate* isolate) { |
| 238 v8::Local<v8::Object> object; | 240 v8::Local<v8::Object> object; |
| 239 { | 241 { |
| 240 v8::Context::Scope contextScope(creationContext->CreationContext()); | 242 v8::Context::Scope contextScope(creationContext->CreationContext()); |
| 241 object = v8::Object::New(isolate); | 243 object = v8::Object::New(isolate); |
| 242 } | 244 } |
| 243 for (unsigned i = 0; i < value.size(); ++i) { | 245 for (unsigned i = 0; i < value.size(); ++i) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 // Cannot define in ScriptValue because of the circular dependency between toV8 | 323 // Cannot define in ScriptValue because of the circular dependency between toV8 |
| 322 // and ScriptValue | 324 // and ScriptValue |
| 323 template <typename T> | 325 template <typename T> |
| 324 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) { | 326 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) { |
| 325 return ScriptValue(scriptState, ToV8(std::forward<T>(value), scriptState)); | 327 return ScriptValue(scriptState, ToV8(std::forward<T>(value), scriptState)); |
| 326 } | 328 } |
| 327 | 329 |
| 328 } // namespace blink | 330 } // namespace blink |
| 329 | 331 |
| 330 #endif // ToV8_h | 332 #endif // ToV8_h |
| OLD | NEW |