[gtk+/wip/otte/shader: 52/55] gskslvalue: Add gsk_sl_value_to_string ()



commit 03da60eddcb3a84c21c40d4861657605e3d5a916
Author: Benjamin Otte <otte redhat com>
Date:   Tue Oct 3 02:42:45 2017 +0200

    gskslvalue: Add gsk_sl_value_to_string ()
    
    Very useful to have in gdb.

 gsk/gskslvalue.c        |   17 +++++++++++++++++
 gsk/gskslvalueprivate.h |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/gsk/gskslvalue.c b/gsk/gskslvalue.c
index fce41fa..a143a7f 100644
--- a/gsk/gskslvalue.c
+++ b/gsk/gskslvalue.c
@@ -20,6 +20,7 @@
 
 #include "gskslvalueprivate.h"
 
+#include "gskslprinterprivate.h"
 #include "gsksltypeprivate.h"
 #include "gskspvwriterprivate.h"
 
@@ -279,6 +280,22 @@ gsk_sl_value_print (const GskSlValue *value,
   gsk_sl_type_print_value (value->type, printer, value->data);
 }
 
+char *
+gsk_sl_value_to_string (const GskSlValue *value)
+{
+  GskSlPrinter *printer;
+  char *s;
+
+  printer = gsk_sl_printer_new ();
+
+  gsk_sl_value_print (value, printer);
+
+  s = gsk_sl_printer_write_to_string (printer);
+  gsk_sl_printer_unref (printer);
+
+  return s;
+}
+
 GskSlType *
 gsk_sl_value_get_type (const GskSlValue *value)
 {
diff --git a/gsk/gskslvalueprivate.h b/gsk/gskslvalueprivate.h
index dc8460e..5790e2b 100644
--- a/gsk/gskslvalueprivate.h
+++ b/gsk/gskslvalueprivate.h
@@ -42,6 +42,7 @@ void                    gsk_sl_value_componentwise              (GskSlValue
                                                                  gpointer             user_data);
 void                    gsk_sl_value_print                      (const GskSlValue    *value,
                                                                  GskSlPrinter        *printer);
+char *                  gsk_sl_value_to_string                  (const GskSlValue    *value);
 
 GskSlType *             gsk_sl_value_get_type                   (const GskSlValue    *value);
 gpointer                gsk_sl_value_get_data                   (const GskSlValue    *value);


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