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

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..780b8715d0f795bbf3dd3149f4f8c3a754c7c99f 100644
--- a/Source/bindings/core/v8/V8BindingMacros.h
+++ b/Source/bindings/core/v8/V8BindingMacros.h
@@ -77,6 +77,22 @@ namespace blink {
if (UNLIKELY(!var.prepare())) \
return retVal;
+template <typename T>
+bool inline getValueFromMaybe(v8::Maybe<T> maybe, T& outVariable)
+{
+ if (maybe.IsNothing())
+ return false;
+ outVariable = maybe.FromJust();
+ return true;
+}
+
+#define V8_CALL(outVariable, handle, methodCall, failureExpression) \
+ if (handle.IsEmpty() || !getValueFromMaybe(handle->methodCall, outVariable)) { \
Jens Widell 2015/03/11 07:18:22 Wrap the whole macro body in a do{}while()? Define
bashi 2015/03/11 07:33:43 Done.
+ do { \
+ failureExpression; \
+ } while (false); \
+ }
+
} // 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