[json-glib] Handle serialization/deserialization of glong gulong and guint64



commit 23e69e79484d41c722ab8bcab78fe850b960316e
Author: Tristan Van Berkom <tristan upstairslabs com>
Date:   Sun Mar 9 17:59:02 2014 +0900

    Handle serialization/deserialization of glong gulong and guint64
    
    Long and unsigned long was properly serialized but not deserialized, guint64
    handling is not ideal as the type is cast into a gint64, however this is
    better than not handling the fundamental type at all.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725972

 json-glib/json-gobject.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/json-glib/json-gobject.c b/json-glib/json-gobject.c
index 3beb0e6..d39088e 100644
--- a/json-glib/json-gobject.c
+++ b/json-glib/json-gobject.c
@@ -553,6 +553,30 @@ json_deserialize_pspec (GValue     *value,
            }
           break;
 
+        case G_TYPE_LONG:
+         if (G_VALUE_HOLDS (&node_value, G_TYPE_INT64))
+           {
+             g_value_set_long (value, (glong) g_value_get_int64 (&node_value));
+             retval = TRUE;
+           }
+          break;
+
+        case G_TYPE_ULONG:
+         if (G_VALUE_HOLDS (&node_value, G_TYPE_INT64))
+           {
+             g_value_set_ulong (value, (gulong) g_value_get_int64 (&node_value));
+             retval = TRUE;
+           }
+          break;
+
+        case G_TYPE_UINT64:
+         if (G_VALUE_HOLDS (&node_value, G_TYPE_INT64))
+           {
+             g_value_set_uint64 (value, (guint64) g_value_get_int64 (&node_value));
+             retval = TRUE;
+           }
+          break;
+
         case G_TYPE_DOUBLE:
 
          if (G_VALUE_HOLDS (&node_value, G_TYPE_DOUBLE))
@@ -695,6 +719,10 @@ json_serialize_pspec (const GValue *real_value,
       retval = json_node_init_int (json_node_alloc (), g_value_get_ulong (real_value));
       break;
 
+    case G_TYPE_UINT64:
+      retval = json_node_init_int (json_node_alloc (), g_value_get_uint64 (real_value));
+      break;
+
     case G_TYPE_FLOAT:
       retval = json_node_init_double (json_node_alloc (), g_value_get_float (real_value));
       break;


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