From 23e69e79484d41c722ab8bcab78fe850b960316e Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Sun, 9 Mar 2014 17:59:02 +0900 Subject: 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 file changed, 28 insertions(+) (limited to 'json-glib/json-gobject.c') 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; -- cgit v1.2.1