[gtk/style-build-fix: 5/5] Build fix for GtkCssValues



commit 8dda7ca6b5bc364bb5e8c5c17360d75720645af4
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 31 09:35:41 2020 +0100

    Build fix for GtkCssValues

 gtk/gtkcssstaticstyle.c  | 10 ++++++----
 gtk/gtkcssstyle.c        | 15 +++++++++++----
 gtk/gtkcssstyleprivate.h |  1 -
 3 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c
index 02cef32758..eeab439844 100644
--- a/gtk/gtkcssstaticstyle.c
+++ b/gtk/gtkcssstaticstyle.c
@@ -172,6 +172,8 @@ static int other_props[] = {
   GTK_CSS_PROPERTY_FILTER,
 };
 
+#define GET_VALUES(v) (GtkCssValue **)((guint8*)(v) + sizeof (GtkCssValues))
+
 #define DEFINE_VALUES(ENUM, TYPE, NAME) \
 void \
 gtk_css_## NAME ## _values_compute_changes_and_affects (GtkCssStyle *style1, \
@@ -179,13 +181,13 @@ gtk_css_## NAME ## _values_compute_changes_and_affects (GtkCssStyle *style1, \
                                                         GtkBitmask    **changes, \
                                                         GtkCssAffects *affects) \
 { \
-  GtkCssValues *g1 = (GtkCssValues *)style1->NAME; \
-  GtkCssValues *g2 = (GtkCssValues *)style2->NAME; \
+  GtkCssValue **g1 = GET_VALUES (style1->NAME); \
+  GtkCssValue **g2 = GET_VALUES (style2->NAME); \
   int i; \
   for (i = 0; i < G_N_ELEMENTS (NAME ## _props); i++) \
     { \
-      GtkCssValue *v1 = g1->values[i] ? g1->values[i] : style1->core->color; \
-      GtkCssValue *v2 = g2->values[i] ? g2->values[i] : style2->core->color; \
+      GtkCssValue *v1 = g1[i] ? g1[i] : style1->core->color; \
+      GtkCssValue *v2 = g2[i] ? g2[i] : style2->core->color; \
       if (!_gtk_css_value_equal (v1, v2)) \
         { \
           guint id = NAME ## _props[i]; \
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c
index 6957e2b126..9637af72b6 100644
--- a/gtk/gtkcssstyle.c
+++ b/gtk/gtkcssstyle.c
@@ -704,6 +704,8 @@ static int values_size[] = {
 
 #define N_VALUES(type) ((values_size[type] - sizeof (GtkCssValues)) / sizeof (GtkCssValue *))
 
+#define GET_VALUES(v) (GtkCssValue **)((guint8 *)(v) + sizeof (GtkCssValues))
+
 GtkCssValues *gtk_css_values_ref (GtkCssValues *values)
 {
   values->ref_count++;
@@ -715,11 +717,12 @@ static void
 gtk_css_values_free (GtkCssValues *values)
 {
   int i;
+  GtkCssValue **v = GET_VALUES (values);
 
   for (i = 0; i < N_VALUES (values->type); i++)
     {
-      if (values->values[i])
-        gtk_css_value_unref (values->values[i]);
+      if (v[i])
+        gtk_css_value_unref (v[i]);
     }
 
   g_free (values);
@@ -740,14 +743,18 @@ GtkCssValues *
 gtk_css_values_copy (GtkCssValues *values)
 {
   GtkCssValues *copy;
+  GtkCssValue **v, **v2;
   int i;
 
   copy = gtk_css_values_new (values->type);
 
+  v = GET_VALUES (values);
+  v2 = GET_VALUES (copy);
+
   for (i = 0; i < N_VALUES (values->type); i++)
     {
-      if (values->values[i])
-        copy->values[i] = gtk_css_value_ref (values->values[i]);
+      if (v[i])
+        v2[i] = gtk_css_value_ref (v[i]);
     }
 
   return copy;
diff --git a/gtk/gtkcssstyleprivate.h b/gtk/gtkcssstyleprivate.h
index 929d200f4b..2a0af9ce90 100644
--- a/gtk/gtkcssstyleprivate.h
+++ b/gtk/gtkcssstyleprivate.h
@@ -65,7 +65,6 @@ typedef struct _GtkCssOtherValues GtkCssOtherValues;
 struct _GtkCssValues {
   int ref_count;
   GtkCssValuesType type;
-  GtkCssValue *values[];
 };
 
 struct _GtkCssCoreValues {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]