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

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

Issue 2709983004: WIP bindings: Add support for the record<K,V> WebIDL type. (Closed)
Patch Set: Rebased patch using NativeValueTraits for IDL types 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return toV8SequenceInternal(value, creationContext, isolate); 232 return toV8SequenceInternal(value, creationContext, isolate);
233 } 233 }
234 234
235 template <typename T, size_t inlineCapacity> 235 template <typename T, size_t inlineCapacity>
236 inline v8::Local<v8::Value> ToV8(const HeapVector<T, inlineCapacity>& value, 236 inline v8::Local<v8::Value> ToV8(const HeapVector<T, inlineCapacity>& value,
237 v8::Local<v8::Object> creationContext, 237 v8::Local<v8::Object> creationContext,
238 v8::Isolate* isolate) { 238 v8::Isolate* isolate) {
239 return toV8SequenceInternal(value, creationContext, isolate); 239 return toV8SequenceInternal(value, creationContext, isolate);
240 } 240 }
241 241
242 // The following two overloads are also used to convert record<K,V> IDL types
243 // back into ECMAScript Objects.
242 template <typename T> 244 template <typename T>
243 inline v8::Local<v8::Value> ToV8(const Vector<std::pair<String, T>>& value, 245 inline v8::Local<v8::Value> ToV8(const Vector<std::pair<String, T>>& value,
244 v8::Local<v8::Object> creationContext, 246 v8::Local<v8::Object> creationContext,
245 v8::Isolate* isolate) { 247 v8::Isolate* isolate) {
246 v8::Local<v8::Object> object; 248 v8::Local<v8::Object> object;
247 { 249 {
248 v8::Context::Scope contextScope(creationContext->CreationContext()); 250 v8::Context::Scope contextScope(creationContext->CreationContext());
249 object = v8::Object::New(isolate); 251 object = v8::Object::New(isolate);
250 } 252 }
251 for (unsigned i = 0; i < value.size(); ++i) { 253 for (unsigned i = 0; i < value.size(); ++i) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // Cannot define in ScriptValue because of the circular dependency between toV8 310 // Cannot define in ScriptValue because of the circular dependency between toV8
309 // and ScriptValue 311 // and ScriptValue
310 template <typename T> 312 template <typename T>
311 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) { 313 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) {
312 return ScriptValue(scriptState, ToV8(std::forward<T>(value), scriptState)); 314 return ScriptValue(scriptState, ToV8(std::forward<T>(value), scriptState));
313 } 315 }
314 316
315 } // namespace blink 317 } // namespace blink
316 318
317 #endif // ToV8_h 319 #endif // ToV8_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698