From d87b18675ac02f42be23bf4070134690b8b9934b Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 12 Aug 2009 12:13:11 +0100 Subject: Auto-promote integer types to G_TYPE_INT64 The JSON RFC does not specify the size of the integer type, thus implicitly falling back to machine-size. This would all be fine and dandy if some demented Web Developer (and I use the term "developer" *very much* loosely) did not decide to use integers to store unique identifiers for objects; obviously, you can't have more than 2^32-1 status messages in a database with millions of users who update their status multiple times per day. Right, Twitter? Anyway, some languages do a type auto-promotion from Integer to Long, thus pushing the limit of allowed positive values -- until the next integer overflow, that is. C, and GLib, do not do that transparently for us so we need to: - always use gint64 when parsing a JSON data stream using JsonScanner - move all the Node, Object and Array APIs to gint64 - auto-promote G_TYPE_INT to G_TYPE_INT64 when setting a GValue manually - auto-promote and auto-demote G_TYPE_INT properties when (de)serializing GObjects. The GLib types used internally by JSON-GLib are, thus: integer -> G_TYPE_INT64 boolean -> G_TYPE_BOOLEAN float -> G_TYPE_DOUBLE string -> G_TYPE_STRING --- json-glib/json-array.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'json-glib/json-array.c') diff --git a/json-glib/json-array.c b/json-glib/json-array.c index 08e0449..16f36a4 100644 --- a/json-glib/json-array.c +++ b/json-glib/json-array.c @@ -241,7 +241,7 @@ json_array_get_element (JsonArray *array, * * Since: 0.8 */ -gint +gint64 json_array_get_int_element (JsonArray *array, guint index_) { @@ -483,7 +483,7 @@ json_array_add_element (JsonArray *array, */ void json_array_add_int_element (JsonArray *array, - gint value) + gint64 value) { JsonNode *node; -- cgit v1.2.1