summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@theqtcompany.com>2015-01-14 17:06:03 +0100
committerPierre Rossi <pierre.rossi@theqtcompany.com>2015-01-22 20:01:40 +0100
commit82bef8eb423bc7a9f607fda95cd980a8b2816056 (patch)
tree4e49034442bb2bad4fb84beb0cf3fd719e197a99 /src/core
parent4c724c022664286191558803632d45cd28749ae4 (diff)
Introduce ASSERT_ENUMS_MATCH macro
For our common use case of compile-time checking enums that we want to keep in sync. Change-Id: I102d737ad986bf3dfff4d11a91afa3f3819a7947 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/qtwebenginecoreglobal.h2
-rw-r--r--src/core/web_contents_delegate_qt.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/core/qtwebenginecoreglobal.h b/src/core/qtwebenginecoreglobal.h
index 9a222f43f..541406f87 100644
--- a/src/core/qtwebenginecoreglobal.h
+++ b/src/core/qtwebenginecoreglobal.h
@@ -57,4 +57,6 @@
# define QWEBENGINE_EXPORT
#endif
+#define ASSERT_ENUMS_MATCH(A, B) Q_STATIC_ASSERT_X(static_cast<int>(A) == static_cast<int>(B), "The enum values must match");
+
#endif // QTWEBENGINECOREGLOBAL_H
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 18b61cd2d..94c6a9a15 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -224,8 +224,8 @@ bool WebContentsDelegateQt::IsFullscreenForTabOrPending(const content::WebConten
return m_viewClient->isFullScreen();
}
-Q_STATIC_ASSERT_X(static_cast<int>(WebContentsAdapterClient::Open) == static_cast<int>(content::FileChooserParams::Open), "Enums out of sync");
-Q_STATIC_ASSERT_X(static_cast<int>(WebContentsAdapterClient::Save) == static_cast<int>(content::FileChooserParams::Save), "Enums out of sync");
+ASSERT_ENUMS_MATCH(WebContentsAdapterClient::Open, content::FileChooserParams::Open)
+ASSERT_ENUMS_MATCH(WebContentsAdapterClient::Save, content::FileChooserParams::Save)
void WebContentsDelegateQt::RunFileChooser(content::WebContents *web_contents, const content::FileChooserParams &params)
{