| 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 |
| 11 #include "bindings/core/v8/DOMDataStore.h" | 11 #include "bindings/core/v8/DOMDataStore.h" |
| 12 #include "bindings/core/v8/IDLDictionaryBase.h" |
| 12 #include "bindings/core/v8/ScriptState.h" | 13 #include "bindings/core/v8/ScriptState.h" |
| 13 #include "bindings/core/v8/ScriptValue.h" | 14 #include "bindings/core/v8/ScriptValue.h" |
| 14 #include "bindings/core/v8/ScriptWrappable.h" | 15 #include "bindings/core/v8/ScriptWrappable.h" |
| 15 #include "bindings/core/v8/V8Binding.h" | 16 #include "bindings/core/v8/V8Binding.h" |
| 16 #include "core/CoreExport.h" | 17 #include "core/CoreExport.h" |
| 17 #include "platform/heap/Handle.h" | 18 #include "platform/heap/Handle.h" |
| 18 #include "wtf/Forward.h" | 19 #include "wtf/Forward.h" |
| 19 #include <utility> | 20 #include <utility> |
| 20 #include <v8.h> | 21 #include <v8.h> |
| 21 | 22 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 187 } |
| 187 | 188 |
| 188 // Dictionary | 189 // Dictionary |
| 189 | 190 |
| 190 inline v8::Local<v8::Value> toV8(const Dictionary& value, v8::Local<v8::Object>
creationContext, v8::Isolate*) | 191 inline v8::Local<v8::Value> toV8(const Dictionary& value, v8::Local<v8::Object>
creationContext, v8::Isolate*) |
| 191 { | 192 { |
| 192 RELEASE_NOTREACHED(); | 193 RELEASE_NOTREACHED(); |
| 193 return v8::Local<v8::Value>(); | 194 return v8::Local<v8::Value>(); |
| 194 } | 195 } |
| 195 | 196 |
| 197 inline v8::Local<v8::Value> toV8(const IDLDictionaryBase& value, v8::Local<v8::O
bject> creationContext, v8::Isolate* isolate) |
| 198 { |
| 199 return value.toV8Impl(creationContext, isolate); |
| 200 } |
| 201 |
| 196 // Array | 202 // Array |
| 197 | 203 |
| 198 template<typename Sequence> | 204 template<typename Sequence> |
| 199 inline v8::Local<v8::Value> toV8SequenceInternal(const Sequence& sequence, v8::L
ocal<v8::Object> creationContext, v8::Isolate* isolate) | 205 inline v8::Local<v8::Value> toV8SequenceInternal(const Sequence& sequence, v8::L
ocal<v8::Object> creationContext, v8::Isolate* isolate) |
| 200 { | 206 { |
| 201 v8::Local<v8::Array> array; | 207 v8::Local<v8::Array> array; |
| 202 { | 208 { |
| 203 v8::Context::Scope contextScope(creationContext->CreationContext()); | 209 v8::Context::Scope contextScope(creationContext->CreationContext()); |
| 204 array = v8::Array::New(isolate, sequence.size()); | 210 array = v8::Array::New(isolate, sequence.size()); |
| 205 } | 211 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 // Cannot define in ScriptValue because of the circular dependency between toV8
and ScriptValue | 273 // Cannot define in ScriptValue because of the circular dependency between toV8
and ScriptValue |
| 268 template<typename T> | 274 template<typename T> |
| 269 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) | 275 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) |
| 270 { | 276 { |
| 271 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState)); | 277 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState)); |
| 272 } | 278 } |
| 273 | 279 |
| 274 } // namespace blink | 280 } // namespace blink |
| 275 | 281 |
| 276 #endif // ToV8_h | 282 #endif // ToV8_h |
| OLD | NEW |