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

Unified Diff: Source/wtf/Assertions.h

Issue 27459002: Move DEFINE_TYPE_CASTS from Node.h to Assertions.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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 | « Source/core/dom/Node.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/Assertions.h
diff --git a/Source/wtf/Assertions.h b/Source/wtf/Assertions.h
index 1a68d704ab2a3faab1ba67040904a0fa01f0e96e..b78200aa159c8aa1c2dc09721154cfe90aff4c02 100644
--- a/Source/wtf/Assertions.h
+++ b/Source/wtf/Assertions.h
@@ -376,4 +376,30 @@ static inline void UNREACHABLE_FOR_PLATFORM()
#define RELEASE_ASSERT_NOT_REACHED() ASSERT_NOT_REACHED()
#endif
+/* DEFINE_TYPE_CASTS */
+
+#define DEFINE_TYPE_CASTS(thisType, argumentType, argumentName, pointerPredicate, referencePredicate) \
+inline thisType* to##thisType(argumentType* argumentName) \
+{ \
+ ASSERT_WITH_SECURITY_IMPLICATION(!argumentName || (pointerPredicate)); \
+ return static_cast<thisType*>(argumentName); \
+} \
+inline const thisType* to##thisType(const argumentType* argumentName) \
+{ \
+ ASSERT_WITH_SECURITY_IMPLICATION(!argumentName || (pointerPredicate)); \
+ return static_cast<const thisType*>(argumentName); \
+} \
+inline thisType& to##thisType(argumentType& argumentName) \
+{ \
+ ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
+ return static_cast<thisType&>(argumentName); \
+} \
+inline const thisType& to##thisType(const argumentType& argumentName) \
+{ \
+ ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
+ return static_cast<const thisType&>(argumentName); \
+} \
+void to##thisType(const thisType*); \
+void to##thisType(const thisType&)
+
#endif /* WTF_Assertions_h */
« no previous file with comments | « Source/core/dom/Node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698