[gegl] argv-serialization: refactor handling of numbers



commit 103c8a6aef048d519ecbc32fd48b445136faf6f6
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Mar 30 15:56:29 2016 +0200

    argv-serialization: refactor handling of numbers

 gegl/gegl-serialize.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/gegl/gegl-serialize.c b/gegl/gegl-serialize.c
index c46b600..1743723 100644
--- a/gegl/gegl-serialize.c
+++ b/gegl/gegl-serialize.c
@@ -168,16 +168,22 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
             }
             else
             if (g_type_is_a (target_type, G_TYPE_DOUBLE) ||
-                g_type_is_a (target_type, G_TYPE_FLOAT))
+                g_type_is_a (target_type, G_TYPE_FLOAT) ||
+                g_type_is_a (target_type, G_TYPE_INT))
               {
-                double val = g_strtod (value, NULL);
-                gegl_node_set (iter[level], key, val, NULL);
+                if (g_type_is_a (target_type, G_TYPE_INT))
+                  gegl_node_set (iter[level], key, 
+                     (int)g_strtod (value, NULL), NULL);
+                else
+                  gegl_node_set (iter[level], key, 
+                     g_strtod (value, NULL), NULL);
               }
-            else if (g_type_is_a (target_type, G_TYPE_BOOLEAN)) {
-            if (!strcmp (value, "true") || !strcmp (value, "TRUE") ||
-                !strcmp (value, "YES") || !strcmp (value, "yes") ||
-                !strcmp (value, "y") || !strcmp (value, "Y") ||
-                !strcmp (value, "1") || !strcmp (value, "on"))
+            else if (g_type_is_a (target_type, G_TYPE_BOOLEAN))
+            {
+              if (!strcmp (value, "true") || !strcmp (value, "TRUE") ||
+                  !strcmp (value, "YES") || !strcmp (value, "yes") ||
+                  !strcmp (value, "y") || !strcmp (value, "Y") ||
+                  !strcmp (value, "1") || !strcmp (value, "on"))
               {
                 gegl_node_set (iter[level], key, TRUE, NULL);
               }
@@ -186,11 +192,6 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
                 gegl_node_set (iter[level], key, FALSE, NULL);
               }
             }
-            else if (g_type_is_a (target_type, G_TYPE_INT))
-            {
-              int val = g_strtod (value, NULL);
-              gegl_node_set (iter[level], key, val, NULL);
-            }
             else if (target_type == GEGL_TYPE_COLOR)
             {
               GeglColor *color = g_object_new (GEGL_TYPE_COLOR,


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