[WPE] Inline wl_array_for_each to workaround C++ compatibility issue
authorcturner@igalia.com <cturner@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2019 08:32:18 +0000 (08:32 +0000)
committercturner@igalia.com <cturner@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2019 08:32:18 +0000 (08:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194898

Reviewed by Žan Doberšek.

* wpe/backends/WindowViewBackend.cpp: wl_array_for_each relies on
a GCC extension that permits arithmetic on void* pointer. Inline
the macro until this issue is fixed upstream.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242344 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/wpe/backends/WindowViewBackend.cpp

index 7dc6211..4cd8ef4 100644 (file)
@@ -1,3 +1,14 @@
+2019-03-04  Charlie Turner  <cturner@igalia.com>
+
+        [WPE] Inline wl_array_for_each to workaround C++ compatibility issue
+        https://bugs.webkit.org/show_bug.cgi?id=194898
+
+        Reviewed by Žan Doberšek.
+
+        * wpe/backends/WindowViewBackend.cpp: wl_array_for_each relies on
+        a GCC extension that permits arithmetic on void* pointer. Inline
+        the macro until this issue is fixed upstream.
+
 2019-03-03  Tim Horton  <timothy_horton@apple.com>
 
         Rid the world of WK_API_ENABLED
index da8cf36..5b2cb81 100644 (file)
@@ -440,10 +440,15 @@ const struct zxdg_toplevel_v6_listener WindowViewBackend::s_xdgToplevelListener
         wpe_view_backend_dispatch_set_size(window.backend(), width, height);
 
         bool isFocused = false;
-        void* p;
-        wl_array_for_each(p, states)
-        {
-            uint32_t state = *static_cast<uint32_t*>(p);
+        // FIXME: It would be nice if the following loop could use
+        // wl_array_for_each, but at the time of writing it relies on
+        // GCC specific extension to work properly:
+        // https://gitlab.freedesktop.org/wayland/wayland/issues/34
+        uint32_t* pos = static_cast<uint32_t*>(states->data);
+        uint32_t* end = static_cast<uint32_t*>(states->data) + states->size;
+
+        for (; pos < end; pos++) {
+            uint32_t state = *pos;
 
             switch (state) {
             case ZXDG_TOPLEVEL_V6_STATE_ACTIVATED: