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

Unified Diff: Source/bindings/core/v8/V8MaybeLocalToLocal.h

Issue 970403003: bindings: Use V8 MaybeLocal APIs in V8DeviceMotionEventCustom (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/core/v8/V8MaybeLocalToLocal.h
diff --git a/Source/bindings/core/v8/V8MaybeLocalToLocal.h b/Source/bindings/core/v8/V8MaybeLocalToLocal.h
new file mode 100644
index 0000000000000000000000000000000000000000..b55a592b0d47dcbc723840572ffa020890951858
--- /dev/null
+++ b/Source/bindings/core/v8/V8MaybeLocalToLocal.h
@@ -0,0 +1,44 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8MaybeLocalToLocal_h
+#define V8MaybeLocalToLocal_h
+
+#include <v8.h>
+
+namespace blink {
+
+template <typename T>
+struct UnwrapV8Local {
+};
+
+template <typename T>
+struct UnwrapV8Local<v8::Local<T>> {
+ typedef T type;
+};
+
+template <typename T>
+struct V8ToMaybeLocal {
+};
+
+template <>
+struct V8ToMaybeLocal<v8::Object> {
+ static v8::MaybeLocal<v8::Object> to(v8::Local<v8::Context> context, v8::Local<v8::Value> value)
+ {
+ return value->ToObject(context);
+ }
+};
+
+// Converts a V8 value to a specific V8 type using ToXXX() methods with checks.
+
+#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
+ using ValueType = UnwrapV8Local<decltype(outValue)>::type; \
+ v8::MaybeLocal<ValueType> maybeValue = V8ToMaybeLocal<ValueType>::to(context, inValue); \
+ if (maybeValue.IsEmpty() || !maybeValue.ToLocal(&outValue)) \
+ return; \
+} while (false);
Yuki 2015/03/04 05:14:31 You don't want the last semi-colon.
+
+} // namespace blink
+
+#endif // V8MaybeLocalToLocal_h

Powered by Google App Engine
This is Rietveld 408576698