msvc does not play nice with them. The wcore struct is always the first
component of the parent wgl struct, thus we should be safe with casting
without calculating/adding the offset (which is 0).

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/wgl/wgl_config.h   |  9 +++++----
 src/waffle/wgl/wgl_context.h  |  9 +++++----
 src/waffle/wgl/wgl_display.h  |  9 +++++----
 src/waffle/wgl/wgl_platform.h |  9 +++++----
 src/waffle/wgl/wgl_window.h   | 10 ++++++----
 5 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/src/waffle/wgl/wgl_config.h b/src/waffle/wgl/wgl_config.h
index 6722398..77f8905 100644
--- a/src/waffle/wgl/wgl_config.h
+++ b/src/waffle/wgl/wgl_config.h
@@ -46,10 +46,11 @@ struct wgl_config {
     struct wgl_window *window;
 };
 
-DEFINE_CONTAINER_CAST_FUNC(wgl_config,
-                           struct wgl_config,
-                           struct wcore_config,
-                           wcore)
+static inline struct wgl_config*
+wgl_config(struct wcore_config *wcore)
+{
+       return (struct wgl_config *)wcore;
+}
 
 struct wcore_config*
 wgl_config_choose(struct wcore_platform *wc_plat,
diff --git a/src/waffle/wgl/wgl_context.h b/src/waffle/wgl/wgl_context.h
index 5396ff4..c55ad58 100644
--- a/src/waffle/wgl/wgl_context.h
+++ b/src/waffle/wgl/wgl_context.h
@@ -38,10 +38,11 @@ struct wgl_context {
     HGLRC hglrc;
 };
 
-DEFINE_CONTAINER_CAST_FUNC(wgl_context,
-                           struct wgl_context,
-                           struct wcore_context,
-                           wcore)
+static inline struct wgl_context*
+wgl_context(struct wcore_context *wcore)
+{
+       return (struct wgl_context *)wcore;
+}
 
 struct wcore_context*
 wgl_context_create(struct wcore_platform *wc_plat,
diff --git a/src/waffle/wgl/wgl_display.h b/src/waffle/wgl/wgl_display.h
index d916f78..d0d94fe 100644
--- a/src/waffle/wgl/wgl_display.h
+++ b/src/waffle/wgl/wgl_display.h
@@ -63,10 +63,11 @@ struct wgl_display {
     PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
 };
 
-DEFINE_CONTAINER_CAST_FUNC(wgl_display,
-                           struct wgl_display,
-                           struct wcore_display,
-                           wcore)
+static inline struct wgl_display*
+wgl_display(struct wcore_display *wcore)
+{
+       return (struct wgl_display*)wcore;
+}
 
 struct wcore_display*
 wgl_display_connect(struct wcore_platform *wc_plat,
diff --git a/src/waffle/wgl/wgl_platform.h b/src/waffle/wgl/wgl_platform.h
index 9223aea..a25d2f4 100644
--- a/src/waffle/wgl/wgl_platform.h
+++ b/src/waffle/wgl/wgl_platform.h
@@ -43,10 +43,11 @@ struct wgl_platform {
     const char *class_name;
 };
 
-DEFINE_CONTAINER_CAST_FUNC(wgl_platform,
-                           struct wgl_platform,
-                           struct wcore_platform,
-                           wcore)
+static inline struct wgl_platform*
+wgl_platform(struct wcore_platform *wcore)
+{
+       return (struct wgl_platform*)wcore;
+}
 
 struct wcore_platform*
 wgl_platform_create(void);
diff --git a/src/waffle/wgl/wgl_window.h b/src/waffle/wgl/wgl_window.h
index 787054a..a60205d 100644
--- a/src/waffle/wgl/wgl_window.h
+++ b/src/waffle/wgl/wgl_window.h
@@ -39,10 +39,12 @@ struct wgl_window {
     bool created;
 };
 
-DEFINE_CONTAINER_CAST_FUNC(wgl_window,
-                           struct wgl_window,
-                           struct wcore_window,
-                           wcore)
+static inline struct wgl_window*
+wgl_window(struct wcore_window *wcore)
+{
+       return (struct wgl_window*)wcore;
+}
+
 struct wcore_window*
 wgl_window_priv_create(struct wcore_platform *wc_plat,
                        struct wcore_config *wc_config,
-- 
2.0.2

_______________________________________________
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle

Reply via email to