[gtk+/wip/otte/shader: 35/51] gsksltype: Generate better type names



commit 0cd87dc2ce62d54caa6478a24317f2ff35eaa6cb
Author: Benjamin Otte <otte redhat com>
Date:   Thu Sep 28 03:42:57 2017 +0200

    gsksltype: Generate better type names
    
    If multiple consecutive struct names share their types, use comma
    notation to goup them.

 gsk/gsksltype.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/gsk/gsksltype.c b/gsk/gsksltype.c
index 74404ac..b0570f5 100644
--- a/gsk/gsksltype.c
+++ b/gsk/gsksltype.c
@@ -1717,7 +1717,7 @@ static char *
 gsk_sl_type_builder_generate_name (GskSlTypeBuilder *builder)
 {
   GString *string = g_string_new ("struct { ");
-  guint i;
+  guint i, j;
 
   for (i = 0; i < builder->members->len; i++)
     {
@@ -1725,6 +1725,15 @@ gsk_sl_type_builder_generate_name (GskSlTypeBuilder *builder)
       g_string_append (string, gsk_sl_type_get_name (m->type));
       g_string_append (string, " ");
       g_string_append (string, m->name);
+      for (j = i + 1; j < builder->members->len; j++)
+        {
+          GskSlTypeMember *n = &g_array_index (builder->members, GskSlTypeMember, j);
+          if (!gsk_sl_type_equal (m->type, n->type))
+            break;
+          g_string_append (string, ", ");
+          g_string_append (string, n->name);
+        }
+      i = j - 1;
       g_string_append (string, "; ");
     }
   g_string_append (string, "}");


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