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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ToV8.h

Issue 2732093003: bindings: Add support for the record<K,V> WebIDL type. (Closed)
Patch Set: s/isolate->GetCurrentContext()/context/ Created 3 years, 9 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
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698