aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Versace <chad.versace@linux.intel.com>2014-07-01 15:58:09 -0700
committerChad Versace <chad.versace@linux.intel.com>2014-07-03 16:45:36 -0700
commit675c809c68357a7af05a9d13d3a0e907d6ffda6a (patch)
treeb355ce22044a562f76a2dc13223681e5da96d342
parentbc9c58e7539d1387fcc60555e645e0b90bcb81ae (diff)
downloadwaffle-675c809c68357a7af05a9d13d3a0e907d6ffda6a.tar.gz
core: Remove empty structs from core objects
Emil discovered that MSVC does rejects empty structs with the error message "C requires that a struct or union has at least one member". This patch removes all empty structs from the wcore objects, and replaces each with a pair of safe typecast functions that provide bidirectional casting waffle_OBJ <-> wcore_OBJ. Reported-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r--src/waffle/api/waffle_config.c2
-rw-r--r--src/waffle/api/waffle_context.c2
-rw-r--r--src/waffle/api/waffle_display.c2
-rw-r--r--src/waffle/api/waffle_window.c2
-rw-r--r--src/waffle/core/wcore_config.h15
-rw-r--r--src/waffle/core/wcore_context.h15
-rw-r--r--src/waffle/core/wcore_display.h15
-rw-r--r--src/waffle/core/wcore_window.h14
8 files changed, 39 insertions, 28 deletions
diff --git a/src/waffle/api/waffle_config.c b/src/waffle/api/waffle_config.c
index 107f07d..01843d9 100644
--- a/src/waffle/api/waffle_config.c
+++ b/src/waffle/api/waffle_config.c
@@ -56,7 +56,7 @@ waffle_config_choose(
if (!wc_self)
return NULL;
- return &wc_self->wfl;
+ return waffle_config(wc_self);
}
WAFFLE_API bool
diff --git a/src/waffle/api/waffle_context.c b/src/waffle/api/waffle_context.c
index b246a63..00649ba 100644
--- a/src/waffle/api/waffle_context.c
+++ b/src/waffle/api/waffle_context.c
@@ -54,7 +54,7 @@ waffle_context_create(
if (!wc_self)
return NULL;
- return &wc_self->wfl;
+ return waffle_context(wc_self);
}
WAFFLE_API bool
diff --git a/src/waffle/api/waffle_display.c b/src/waffle/api/waffle_display.c
index 9d741e9..fa19462 100644
--- a/src/waffle/api/waffle_display.c
+++ b/src/waffle/api/waffle_display.c
@@ -42,7 +42,7 @@ waffle_display_connect(const char *name)
if (!wc_self)
return NULL;
- return &wc_self->wfl;
+ return waffle_display(wc_self);
}
WAFFLE_API bool
diff --git a/src/waffle/api/waffle_window.c b/src/waffle/api/waffle_window.c
index 1dbf823..207ef33 100644
--- a/src/waffle/api/waffle_window.c
+++ b/src/waffle/api/waffle_window.c
@@ -54,7 +54,7 @@ waffle_window_create(
if (!wc_self)
return NULL;
- return &wc_self->wfl;
+ return waffle_window(wc_self);
}
WAFFLE_API bool
diff --git a/src/waffle/core/wcore_config.h b/src/waffle/core/wcore_config.h
index 9c3597e..7911f56 100644
--- a/src/waffle/core/wcore_config.h
+++ b/src/waffle/core/wcore_config.h
@@ -40,17 +40,20 @@ struct wcore_config;
union waffle_native_config;
struct wcore_config {
- struct waffle_config {} wfl;
struct api_object api;
struct wcore_config_attrs attrs;
-
struct wcore_display *display;
};
-DEFINE_CONTAINER_CAST_FUNC(wcore_config,
- struct wcore_config,
- struct waffle_config,
- wfl)
+static inline struct waffle_config*
+waffle_config(struct wcore_config *cfg) {
+ return (struct waffle_config*) cfg;
+}
+
+static inline struct wcore_config*
+wcore_config(struct waffle_config *cfg) {
+ return (struct wcore_config*) cfg;
+}
static inline bool
wcore_config_init(struct wcore_config *self,
diff --git a/src/waffle/core/wcore_context.h b/src/waffle/core/wcore_context.h
index 548da50..fb67e4c 100644
--- a/src/waffle/core/wcore_context.h
+++ b/src/waffle/core/wcore_context.h
@@ -39,16 +39,19 @@ struct wcore_display;
union waffle_native_context;
struct wcore_context {
- struct waffle_context {} wfl;
struct api_object api;
-
struct wcore_display *display;
};
-DEFINE_CONTAINER_CAST_FUNC(wcore_context,
- struct wcore_context,
- struct waffle_context,
- wfl)
+static inline struct waffle_context*
+waffle_context(struct wcore_context *ctx) {
+ return (struct waffle_context*) ctx;
+}
+
+static inline struct wcore_context*
+wcore_context(struct waffle_context *ctx) {
+ return (struct wcore_context*) ctx;
+}
static inline bool
wcore_context_init(struct wcore_context *self,
diff --git a/src/waffle/core/wcore_display.h b/src/waffle/core/wcore_display.h
index f67bf03..0b95729 100644
--- a/src/waffle/core/wcore_display.h
+++ b/src/waffle/core/wcore_display.h
@@ -34,16 +34,19 @@ struct wcore_platform;
union waffle_native_display;
struct wcore_display {
- struct waffle_display {} wfl;
struct api_object api;
-
struct wcore_platform *platform;
};
-DEFINE_CONTAINER_CAST_FUNC(wcore_display,
- struct wcore_display,
- struct waffle_display,
- wfl)
+static inline struct waffle_display*
+waffle_display(struct wcore_display *dpy) {
+ return (struct waffle_display*) dpy;
+}
+
+static inline struct wcore_display*
+wcore_display(struct waffle_display *dpy) {
+ return (struct wcore_display*) dpy;
+}
bool
wcore_display_init(struct wcore_display *self,
diff --git a/src/waffle/core/wcore_window.h b/src/waffle/core/wcore_window.h
index fc82111..20a154b 100644
--- a/src/waffle/core/wcore_window.h
+++ b/src/waffle/core/wcore_window.h
@@ -32,17 +32,19 @@ struct wcore_window;
union waffle_native_window;
struct wcore_window {
- struct waffle_window {} wfl;
struct api_object api;
-
struct wcore_display *display;
};
-DEFINE_CONTAINER_CAST_FUNC(wcore_window,
- struct wcore_window,
- struct waffle_window,
- wfl)
+static inline struct waffle_window*
+waffle_window(struct wcore_window *win) {
+ return (struct waffle_window*) win;
+}
+static inline struct wcore_window*
+wcore_window(struct waffle_window *win) {
+ return (struct wcore_window*) win;
+}
static inline bool
wcore_window_init(struct wcore_window *self,