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

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

Issue 995203002: bindings: Add a macro for V8 Maybe<T> APIs. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/modules/v8/custom/V8CustomSQLStatementErrorCallback.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | Source/bindings/modules/v8/custom/V8CustomSQLStatementErrorCallback.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698