Index: Source/bindings/core/v8/V8BindingMacros.h |
diff --git a/Source/bindings/core/v8/V8BindingMacros.h b/Source/bindings/core/v8/V8BindingMacros.h |
index 77a7faafd9a59fd952e4ad244a637f205fda3013..b9864b763c8a0fde933b17ac49321a23c53ca217 100644 |
--- a/Source/bindings/core/v8/V8BindingMacros.h |
+++ b/Source/bindings/core/v8/V8BindingMacros.h |
@@ -77,6 +77,21 @@ namespace blink { |
if (UNLIKELY(!var.prepare())) \ |
return retVal; |
+template <typename T> |
+inline bool getValueFromMaybe(v8::Maybe<T> maybe, T& outVariable) |
+{ |
+ if (maybe.IsNothing()) |
+ return false; |
+ outVariable = maybe.FromJust(); |
+ return true; |
+} |
+ |
+// The last "else" is to avoid dangling else problem. |
+#define V8_CALL(outVariable, handle, methodCall, failureExpression) \ |
+ if (handle.IsEmpty() || !getValueFromMaybe(handle->methodCall, outVariable)) { \ |
+ failureExpression; \ |
+ } else |
+ |
} // namespace blink |
#endif // V8BindingMacros_h |