diff options
-rwxr-xr-x | autogen.sh | 28 | ||||
-rw-r--r-- | configure.ac | 19 | ||||
-rw-r--r-- | json-glib/Makefile.am | 1 | ||||
-rw-r--r-- | json-glib/json-gobject.c | 15 | ||||
-rw-r--r-- | tests/test-serialize-full.c | 29 |
5 files changed, 70 insertions, 22 deletions
@@ -1,4 +1,26 @@ #! /bin/sh -gtkdocize || exit 1 -autoreconf -v --install || exit 1 -./configure "$@" + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +PROJECT=JSON-GLib +TEST_TYPE=-d +FILE=json-glib + +test ${TEST_TYPE} ${FILE} || { + echo "You must run this script in the top-level ${PROJECT} directory" + exit 1 +} + +GTKDOCIZE=`which gtkdocize` +if test -z $GTKDOCIZE; then + echo "*** No gtk-doc support ***" + echo "EXTRA_DIST =" > gtk-doc.make +else + gtkdocize || exit $? +fi + +autoreconf -v --install || exit $? + +./configure "$@" && echo "Now type 'make' to compile ${PROJECT}" + diff --git a/configure.ac b/configure.ac index 30f1365..6b6eee4 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,12 @@ m4_define([lt_age], m4_define([glib_req_version], [2.15]) AC_PREREQ([2.59]) -AC_INIT([json-glib], [json_version], [], [json-glib]) + +AC_INIT([json-glib], + [json_version], + [http://bugzilla.openedhand.com/enter_bug.cgi], + [json-glib]) + AC_CONFIG_SRCDIR([json-glib/json-glib.h]) AM_INIT_AUTOMAKE([1.9]) @@ -41,7 +46,7 @@ JSON_LT_CURRENT=lt_current JSON_LT_REVISION=lt_revision JSON_LT_AGE=lt_age JSON_LT_VERSION="$JSON_LT_CURRENT:$JSON_LT_REVISION:$JSON_LT_AGE" -JSON_LT_LDFLAGS="-versio-info $JSON_LT_VERSION" +JSON_LT_LDFLAGS="-version-info $JSON_LT_VERSION" AC_SUBST(JSON_LT_LDFLAGS) AC_PROG_CC @@ -76,7 +81,7 @@ dnl = Enable debug level =================================================== m4_define([debug_default], m4_if(m4_eval(json_minor_version % 2), [1], [yes], [minimum])) -AC_ARG_ENABLE(debug, +AC_ARG_ENABLE([debug], AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes@:>@], [turn on debugging @<:@default=debug_default@:>@]), , @@ -132,9 +137,9 @@ AC_OUTPUT echo "" echo " Json-GLib $VERSION" echo "" -echo " Prefix: ${prefix}" -echo " Debug level: ${enable_debug}" -echo " Compiler flags: ${CPPFLAGS}" -echo " API reference: ${enable_gtk_doc}" +echo " Prefix: ${prefix}" +echo " Debug level: ${enable_debug}" +echo " Compiler flags: ${CPPFLAGS}" +echo " API reference: ${enable_gtk_doc}" echo " Install vala bindings: ${has_vala} (${VAPI_DIR})" echo "" diff --git a/json-glib/Makefile.am b/json-glib/Makefile.am index f65a1c8..b57b78d 100644 --- a/json-glib/Makefile.am +++ b/json-glib/Makefile.am @@ -110,6 +110,7 @@ DISTCLEANFILES = json-version.h EXTRA_DIST += \ json-version.h.in \ + json-scanner.h \ json-glib.h \ json-marshal.list \ json-enum-types.h.in \ diff --git a/json-glib/json-gobject.c b/json-glib/json-gobject.c index b0a0e13..15e9ed5 100644 --- a/json-glib/json-gobject.c +++ b/json-glib/json-gobject.c @@ -189,8 +189,7 @@ json_deserialize_pspec (GValue *value, { JsonArray *array = json_node_get_array (node); guint i, array_len = json_array_get_length (array); - GString *buffer = g_string_new (NULL); - gchar **strv = NULL; + GPtrArray *str_array = g_ptr_array_sized_new (array_len); for (i = 0; i < array_len; i++) { @@ -200,17 +199,13 @@ json_deserialize_pspec (GValue *value, continue; if (json_node_get_string (val) != NULL); - { - g_string_append (buffer, json_node_get_string (val)); - g_string_append_c (buffer, '\v'); - } + g_ptr_array_add (str_array, (gpointer) json_node_get_string (val)); } - strv = g_strsplit (buffer->str, "\v", -1); - g_value_set_boxed (value, strv); + g_value_set_boxed (value, str_array->pdata); + + g_ptr_array_free (str_array, TRUE); - g_strfreev (strv); - g_string_free (buffer, TRUE); retval = TRUE; } break; diff --git a/tests/test-serialize-full.c b/tests/test-serialize-full.c index eea785f..f549fe1 100644 --- a/tests/test-serialize-full.c +++ b/tests/test-serialize-full.c @@ -41,6 +41,7 @@ struct _TestObject gchar *baz; TestBoxed blah; TestEnum meh; + gchar **mah; }; struct _TestObjectClass @@ -112,7 +113,8 @@ enum PROP_BAR, PROP_BAZ, PROP_BLAH, - PROP_MEH + PROP_MEH, + PROP_MAH }; static void json_serializable_iface_init (gpointer g_iface); @@ -192,6 +194,7 @@ static void test_object_finalize (GObject *gobject) { g_free (TEST_OBJECT (gobject)->baz); + g_strfreev (TEST_OBJECT (gobject)->mah); G_OBJECT_CLASS (test_object_parent_class)->finalize (gobject); } @@ -217,6 +220,9 @@ test_object_set_property (GObject *gobject, case PROP_MEH: TEST_OBJECT (gobject)->meh = g_value_get_enum (value); break; + case PROP_MAH: + TEST_OBJECT (gobject)->mah = g_strdupv (g_value_get_boxed (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); } @@ -245,6 +251,9 @@ test_object_get_property (GObject *gobject, case PROP_MEH: g_value_set_enum (value, TEST_OBJECT (gobject)->meh); break; + case PROP_MAH: + g_value_set_boxed (value, TEST_OBJECT (gobject)->mah); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); } @@ -285,6 +294,11 @@ test_object_class_init (TestObjectClass *klass) TEST_TYPE_ENUM, TEST_ENUM_BAR, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_MAH, + g_param_spec_boxed ("mah", "Mah", "Mah", + G_TYPE_STRV, + G_PARAM_READWRITE)); } static void @@ -298,6 +312,8 @@ test_object_init (TestObject *object) object->blah.bar = object->bar; object->meh = TEST_ENUM_BAR; + + object->mah = NULL; } static const gchar *var_test = @@ -305,7 +321,8 @@ static const gchar *var_test = " \"foo\" : 42,\n" " \"bar\" : false,\n" " \"baz\" : \"hello\",\n" -" \"meh\" : \"baz\"\n" +" \"meh\" : \"baz\",\n" +" \"mah\" : [ \"hello\", \", \", \"world\", \"!\" ]\n" "}"; static void @@ -313,6 +330,7 @@ test_deserialize (void) { GObject *object; GError *error; + gchar *str; error = NULL; object = json_construct_gobject (TEST_TYPE_OBJECT, var_test, -1, &error); @@ -335,6 +353,13 @@ test_deserialize (void) g_assert_cmpstr (TEST_OBJECT (object)->baz, ==, "hello"); g_assert_cmpint (TEST_OBJECT (object)->meh, ==, TEST_ENUM_BAZ); + g_assert (TEST_OBJECT (object)->mah != NULL); + g_assert_cmpint (g_strv_length (TEST_OBJECT (object)->mah), ==, 4); + + str = g_strjoinv (NULL, TEST_OBJECT (object)->mah); + g_assert_cmpstr (str, ==, "hello, world!"); + + g_free (str); g_object_unref (object); } |