Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef V8MaybeLocalToLocal_h | |
| 6 #define V8MaybeLocalToLocal_h | |
| 7 | |
| 8 #include <v8.h> | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 template <typename T> | |
| 13 struct UnwrapV8Local { | |
| 14 }; | |
| 15 | |
| 16 template <typename T> | |
| 17 struct UnwrapV8Local<v8::Local<T>> { | |
| 18 typedef T type; | |
| 19 }; | |
| 20 | |
| 21 template <typename T> | |
| 22 struct V8ToMaybeLocal { | |
| 23 }; | |
| 24 | |
| 25 template <> | |
| 26 struct V8ToMaybeLocal<v8::Object> { | |
| 27 static v8::MaybeLocal<v8::Object> to(v8::Local<v8::Context> context, v8::Loc al<v8::Value> value) | |
| 28 { | |
| 29 return value->ToObject(context); | |
| 30 } | |
| 31 }; | |
| 32 | |
| 33 // Converts a V8 value to a specific V8 type using ToXXX() methods with checks. | |
| 34 | |
| 35 #define MAYBE_LOCAL_TO_LOCAL_VOID(context, inValue, outValue) do { \ | |
|
bashi
2015/03/04 04:42:11
I'm planning to add MAYBE_LOCAL_TO_LOCAL_DEFAULT(c
| |
| 36 using ValueType = UnwrapV8Local<decltype(outValue)>::type; \ | |
| 37 v8::MaybeLocal<ValueType> maybeValue = V8ToMaybeLocal<ValueType>::to(context , inValue); \ | |
| 38 if (maybeValue.IsEmpty() || !maybeValue.ToLocal(&outValue)) \ | |
| 39 return; \ | |
| 40 } while (false); | |
|
Yuki
2015/03/04 05:14:31
You don't want the last semi-colon.
| |
| 41 | |
| 42 } // namespace blink | |
| 43 | |
| 44 #endif // V8MaybeLocalToLocal_h | |
| OLD | NEW |