[gegl] gegl: refactor op-api version call to only deal with op names



commit e0f83a989fbc400563ebca902b48a6c9c89efe95
Author: Øyvind Kolås <pippin gimp org>
Date:   Tue Apr 4 17:38:18 2017 +0200

    gegl: refactor op-api version call to only deal with op names
    
    This is better than expecting a GeglNode as an argument for parsing,
    since it doesn't rely on having the generated object around already.

 gegl/gegl-serialize.c  |   16 +++++++++++-----
 gegl/graph/gegl-node.c |    8 +++-----
 gegl/graph/gegl-node.h |    2 +-
 3 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/gegl/gegl-serialize.c b/gegl/gegl-serialize.c
index 2240296..6be9e1f 100644
--- a/gegl/gegl-serialize.c
+++ b/gegl/gegl-serialize.c
@@ -162,9 +162,14 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
           }
           else if (!strcmp (key, "opi"))
           {
-            /* should do check, and at least warn if incompatible,
-               for now just ignore  */
-            g_print ("ignoring opi='%s'", value);
+            /* should check for incompatibility rather than difference */
+            if (!g_str_equal (value, gegl_operation_get_op_version (level_op[level])))
+             {
+                /* for now - just reporting it */
+                g_print ("operation property interface version mismatch for %s\n"
+                         "parsed %s but GEGL library has %s\n",
+                         level_op[level], value, gegl_operation_get_op_version (level_op[level]));
+             }
           }
           else
           {
@@ -563,11 +568,12 @@ static gchar *gegl_serialize2 (GeglNode *start, GeglNode *end, const char *basep
     else
     {
       GString *s2 = g_string_new ("");
+      const char *op_name = gegl_node_get_operation (iter);
       if (!(flags & GEGL_SERIALIZE_INDENT))
         g_string_append_printf (s2, " ");
-      g_string_append_printf (s2, "%s", gegl_node_get_operation (iter));
+      g_string_append_printf (s2, "%s", op_name);
       if (flags & GEGL_SERIALIZE_VERSION)
-        g_string_append_printf (s2, " opi=%s", gegl_node_get_op_version (iter));
+        g_string_append_printf (s2, " opi=%s", gegl_operation_get_op_version (op_name));
       if (flags & GEGL_SERIALIZE_INDENT)
         g_string_append_printf (s2, "\n");
       {
diff --git a/gegl/graph/gegl-node.c b/gegl/graph/gegl-node.c
index ba6fd9a..45d4477 100644
--- a/gegl/graph/gegl-node.c
+++ b/gegl/graph/gegl-node.c
@@ -2215,13 +2215,11 @@ void gegl_node_progress (GeglNode *node,
   }
 }
 
-const char *gegl_node_get_op_version (GeglNode *node)
+const char *gegl_operation_get_op_version (const char *op_name)
 {
-  const gchar *ret = NULL;
-  g_return_val_if_fail (GEGL_IS_NODE (node), "error");
-
-  ret = gegl_operation_get_key (gegl_node_get_operation(node), "op-version");
+  const gchar *ret = gegl_operation_get_key (op_name, "op-version");
   if (!ret)
     ret = "0:0";
   return ret;
 }
+
diff --git a/gegl/graph/gegl-node.h b/gegl/graph/gegl-node.h
index e93a61d..5c392c6 100644
--- a/gegl/graph/gegl-node.h
+++ b/gegl/graph/gegl-node.h
@@ -694,7 +694,7 @@ void           gegl_node_set_passthrough (GeglNode      *node,
 
 void       gegl_node_progress (GeglNode *node, gdouble progress, gchar *message);
 
-const char *gegl_node_get_op_version (GeglNode *node);
+const char *gegl_operation_get_op_version (const gchar *op_name);
 
 G_END_DECLS
 


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