| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 v8::Local<v8::Object> object = v8::Object::New(isolate); | 230 v8::Local<v8::Object> object = v8::Object::New(isolate); |
| 231 for (unsigned i = 0; i < value.size(); ++i) { | 231 for (unsigned i = 0; i < value.size(); ++i) { |
| 232 v8::Local<v8::Value> v8Value = toV8(value[i].second, creationContext, is
olate); | 232 v8::Local<v8::Value> v8Value = toV8(value[i].second, creationContext, is
olate); |
| 233 if (v8Value.IsEmpty()) | 233 if (v8Value.IsEmpty()) |
| 234 v8Value = v8::Undefined(isolate); | 234 v8Value = v8::Undefined(isolate); |
| 235 object->Set(v8String(isolate, value[i].first), v8Value); | 235 object->Set(v8String(isolate, value[i].first), v8Value); |
| 236 } | 236 } |
| 237 return object; | 237 return object; |
| 238 } | 238 } |
| 239 | 239 |
| 240 // Only declare toV8(void*,...) for checking function overload mismatch. |
| 241 // This toV8(void*,...) should be never used. So we will find mismatch |
| 242 // because of "unresolved external symbol". |
| 243 // Without toV8(void*, ...), call to toV8 with T* will match with |
| 244 // toV8(bool, ...) if T is not a subclass of ScriptWrappable or if T is |
| 245 // declared but not defined (so it's not clear that T is a subclass of |
| 246 // ScriptWrappable). |
| 247 // This hack helps detect such unwanted implicit conversions from T* to bool. |
| 248 v8::Handle<v8::Value> toV8(void* value, v8::Handle<v8::Object> creationContext,
v8::Isolate*); |
| 249 |
| 240 } // namespace blink | 250 } // namespace blink |
| 241 | 251 |
| 242 #endif // ToV8_h | 252 #endif // ToV8_h |
| OLD | NEW |