json-glib r22 - in trunk: . debian doc/reference json-glib tests
- From: ebassi svn gnome org
- To: svn-commits-list gnome org
- Subject: json-glib r22 - in trunk: . debian doc/reference json-glib tests
- Date: Mon, 5 May 2008 13:29:35 +0100 (BST)
Author: ebassi
Date: Mon May 5 12:29:34 2008
New Revision: 22
URL: http://svn.gnome.org/viewvc/json-glib?rev=22&view=rev
Log:
2008-05-05 Emmanuele Bassi <ebassi openedhand com>
* *: Resync with the main git repository.
Branches: master, debian-packaging
Added:
trunk/.gitignore
trunk/debian/
trunk/debian/changelog
trunk/debian/compat
trunk/debian/control
trunk/debian/copyright
trunk/debian/libjson-glib-dev.install
trunk/debian/libjson-glib-doc.install
trunk/debian/libjson-glib-doc.links
trunk/debian/libjson-glib0.install
trunk/debian/rules
trunk/json-glib/json-enum-types.c.in
trunk/json-glib/json-enum-types.h.in
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/README
trunk/autogen.sh
trunk/configure.ac
trunk/doc/reference/Makefile.am
trunk/doc/reference/json-glib-sections.txt
trunk/json-glib/Makefile.am
trunk/json-glib/json-glib.h
trunk/json-glib/json-gobject.c
trunk/json-glib/json-node.c
trunk/json-glib/json-scanner.h
trunk/tests/test-parser.c
trunk/tests/test-serialize-full.c
trunk/tests/test-serialize-simple.c
Added: trunk/.gitignore
==============================================================================
--- (empty file)
+++ trunk/.gitignore Mon May 5 12:29:34 2008
@@ -0,0 +1,88 @@
+INSTALL
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+configure
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+depcomp
+doc/reference/version.xml
+gtk-doc.make
+install-sh
+json-glib-1.0.pc
+json-glib.pc
+json-glib/.deps
+json-glib/.libs
+json-glib/json-array.lo
+json-glib/json-enum-types.c
+json-glib/json-enum-types.h
+json-glib/json-enum-types.lo
+json-glib/json-generator.lo
+json-glib/json-gobject.lo
+json-glib/json-marshal.c
+json-glib/json-marshal.h
+json-glib/json-marshal.lo
+json-glib/json-node.lo
+json-glib/json-object.lo
+json-glib/json-parser.lo
+json-glib/json-scanner.lo
+json-glib/json-version.h
+json-glib/libjson-glib-1.0.la
+json-glib/stamp-json-enum-types.h
+json-glib/stamp-json-marshal.h
+json-glib/tests/.deps
+json-glib/tests/.libs
+json-glib/tests/array-test
+json-glib/tests/array-test.o
+json-glib/tests/object-test
+json-glib/tests/object-test.o
+json-glib/tests/node-test
+json-glib/tests/node-test.o
+libtool
+ltmain.sh
+missing
+stamp-h1
+test-report.xml
+tests/.deps
+tests/.libs
+tests/test-parser
+tests/test-parser.o
+tests/test-generator
+tests/test-generator.o
+tests/test-serialize-simple
+tests/test-serialize-simple.o
+tests/test-serialize-complex
+tests/test-serialize-complex.o
+tests/test-serialize-full
+tests/test-serialize-full.o
+.*.swp
+doc/reference/.libs
+doc/reference/html-build.stamp
+doc/reference/html.stamp
+doc/reference/html
+doc/reference/json-glib-decl-list.txt
+doc/reference/json-glib-decl-list.txt.bak
+doc/reference/json-glib-decl.txt
+doc/reference/json-glib-decl.txt.bak
+doc/reference/json-glib-overrides.txt
+doc/reference/json-glib-undeclared.txt
+doc/reference/json-glib-undocumented.txt
+doc/reference/json-glib-unused.txt
+doc/reference/json-glib.args
+doc/reference/json-glib.hierarchy
+doc/reference/json-glib.interfaces
+doc/reference/json-glib.prerequisites
+doc/reference/json-glib.signals
+doc/reference/scan-build.stamp
+doc/reference/sgml-build.stamp
+doc/reference/sgml.stamp
+doc/reference/tmpl-build.stamp
+doc/reference/tmpl.stamp
+doc/reference/tmpl
+doc/reference/xml
+test-report.html
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Mon May 5 12:29:34 2008
@@ -1,3 +1,22 @@
+Overview of changes for 0.6.0
+=============================
+* Allow deserialization of strings into enum and flag types
+* Add the :indent-char property to JsonGenerator
+* Add functions to retrieve copies of the nodes inside Object and Array
+* Fix leaks and invalid accesses
+* Use the right type for the buffer length parameter in JsonParser
+* Provide a default implementation for JsonSerializable
+* Provide our own JSON tokenizer (using GScanner) for the JSON-only
+ features that would have been lost by using GScanner
+* Add a fully automated test suite, using the GTest framework
+* Allow 'null' nodes to return a value without warnings
+* Add support for parsing Unicode characters escaped using \uXXXX
+* Make the deserialization of G_TYPE_STRV properties more robust
+* Export the public symbols only
+* Provide GTypes for the enumerations
+* Avoid a warning when trying to copy an empty JsonNode
+* Fix gtk-doc cross-references with GLib and GObject documentation
+
Overview of changes for 0.4.0
=============================
* Support parsing of negative numbers
Modified: trunk/README
==============================================================================
--- trunk/README (original)
+++ trunk/README Mon May 5 12:29:34 2008
@@ -3,6 +3,11 @@
JSON-GLib implements a full JSON parser using GLib and GObject.
+Use JSON-GLib it is possible to parse and generate valid JSON data
+structures, using a DOM-like API. JSON-GLib also offers GObject
+integration, providing the ability to serialize and deserialize
+GObject instances to and from JSON data types.
+
JSON is the JavaScript Object Notation; it can be used to represent
objects and object hierarchies while retaining human-readability.
@@ -23,7 +28,7 @@
* pkg-config
* gtk-doc >= 1.8
- * GLib >= 2.14
+ * GLib >= 2.16
INSTALLATION
------------
Modified: trunk/autogen.sh
==============================================================================
--- trunk/autogen.sh (original)
+++ trunk/autogen.sh Mon May 5 12:29:34 2008
@@ -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}"
+
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Mon May 5 12:29:34 2008
@@ -1,5 +1,5 @@
m4_define([json_major_version], [0])
-m4_define([json_minor_version], [5])
+m4_define([json_minor_version], [6])
m4_define([json_micro_version], [0])
m4_define([json_version],
@@ -18,7 +18,12 @@
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_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
@@ -51,7 +56,12 @@
AC_FUNC_MALLOC
AC_FUNC_MMAP
+GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`"
+AC_SUBST(GLIB_PREFIX)
+
PKG_CHECK_MODULES(JSON, gobject-2.0 >= glib_req_version)
+AC_SUBST(JSON_CFLAGS)
+AC_SUBST(JSON_LIBS)
has_vala=no
PKG_CHECK_MODULES(JSON_VALA, vala-1.0, has_vala=yes, has_vala=no)
@@ -71,7 +81,7 @@
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@:>@]),
,
@@ -127,9 +137,9 @@
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 ""
Added: trunk/debian/changelog
==============================================================================
--- (empty file)
+++ trunk/debian/changelog Mon May 5 12:29:34 2008
@@ -0,0 +1,6 @@
+json-glib (0.6.0-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Emmanuele Bassi <ebassi openedhand com> Thu, 01 May 2008 15:22:36 +0100
+
Added: trunk/debian/compat
==============================================================================
--- (empty file)
+++ trunk/debian/compat Mon May 5 12:29:34 2008
@@ -0,0 +1 @@
+5
Added: trunk/debian/control
==============================================================================
--- (empty file)
+++ trunk/debian/control Mon May 5 12:29:34 2008
@@ -0,0 +1,61 @@
+Source: json-glib
+Section: libs
+Priority: optional
+Maintainer: Emmanuele Bassi <ebassi openedhand com>
+Uploaders: Rob Bradford <robster debian org>, Ross Burton <ross openedhand com>
+Build-Depends: debhelper (>= 5), cdbs, libglib2.0-dev, gtk-doc-tools
+Standards-Version: 3.7.2
+
+Package: libjson-glib0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: GLib JSON manipulation library
+ JSON-GLib is a library for parsing, generating and manipulating JavaScript
+ Object Notation (JSON) data streams using the GLib type system. It allows
+ manipulating JSON data types with a Document Object Model API. It also
+ allows serializing and deserializing simple or complex GObjects to and
+ from JSON data types.
+
+Package: libjson-glib0-dbg
+Section: libdevel
+Priority: extra
+Architecture: any
+Depends: libjson-glib0 (= ${binary:Version})
+Description: GLib JSON manipulation library (debug symbols)
+ JSON-GLib is a library for parsing, generating and manipulating JavaScript
+ Object Notation (JSON) data streams using the GLib type system. It allows
+ manipulating JSON data types with a Document Object Model API. It also
+ allows serializing and deserializing simple or complex GObjects to and
+ from JSON data types.
+ .
+ This package contains the debug files.
+
+Package: libjson-glib-dev
+Section: libdevel
+Architecture: any
+Depends: libjson-glib0 (= ${binary:Version}), pkg-config, libglib2.0-dev, ${misc:Depends}
+Suggests: libjson-glib-doc
+Description: GLib JSON manipulation library (development files)
+ JSON-GLib is a library for parsing, generating and manipulating JavaScript
+ Object Notation (JSON) data streams using the GLib type system. It allows
+ manipulating JSON data types with a Document Object Model API. It also
+ allows serializing and deserializing simple or complex GObjects to and
+ from JSON data types.
+ .
+ This package contains the development files.
+
+Package: libjson-glib-doc
+Section: doc
+Architecture: all
+Depends: ${misc:Depends}
+Suggests: devhelp
+Description: GLib JSON manipulation library (documentation)
+ JSON-GLib is a library for parsing, generating and manipulating JavaScript
+ Object Notation (JSON) data streams using the GLib type system. It allows
+ manipulating JSON data types with a Document Object Model API. It also
+ allows serializing and deserializing simple or complex GObjects to and
+ from JSON data types.
+ .
+ This package contains the documentation.
+
Added: trunk/debian/copyright
==============================================================================
--- (empty file)
+++ trunk/debian/copyright Mon May 5 12:29:34 2008
@@ -0,0 +1,27 @@
+This package was debianized by Emmanuele Bassi <ebassi openedhand com> on Thu, 01 May 2008 15:31:18 +0100
+
+It was downloaded from:
+ http://folks.o-hand.com/ebassi/source/json-glib-0.6.0.tar.gz
+
+Upstream Authors:
+ Emmanuele Bassi <ebassi openedhand com>
+
+Copyright (C) 2008 OpenedHand Ltd.
+
+License:
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along
+ with this library; if not, write to the Free Software Foundation, Inc., 51
+ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/LGPL-2'.
Added: trunk/debian/libjson-glib-dev.install
==============================================================================
--- (empty file)
+++ trunk/debian/libjson-glib-dev.install Mon May 5 12:29:34 2008
@@ -0,0 +1,3 @@
+debian/tmp/usr/lib/*.so
+debian/tmp/usr/lib/pkgconfig/
+debian/tmp/usr/include/
Added: trunk/debian/libjson-glib-doc.install
==============================================================================
--- (empty file)
+++ trunk/debian/libjson-glib-doc.install Mon May 5 12:29:34 2008
@@ -0,0 +1 @@
+debian/tmp/usr/share/gtk-doc/html/json-glib
Added: trunk/debian/libjson-glib-doc.links
==============================================================================
--- (empty file)
+++ trunk/debian/libjson-glib-doc.links Mon May 5 12:29:34 2008
@@ -0,0 +1 @@
+usr/share/gtk-doc/html/clutter usr/share/doc/libclutter-doc/html
Added: trunk/debian/libjson-glib0.install
==============================================================================
--- (empty file)
+++ trunk/debian/libjson-glib0.install Mon May 5 12:29:34 2008
@@ -0,0 +1 @@
+debian/tmp/usr/lib/*.so.*
Added: trunk/debian/rules
==============================================================================
--- (empty file)
+++ trunk/debian/rules Mon May 5 12:29:34 2008
@@ -0,0 +1,12 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+include /usr/share/cdbs/1/rules/simple-patchsys.mk
+include /usr/share/cdbs/1/rules/utils.mk
+
+DEB_CONFIGURE_SCRIPT_ENV += LDFLAGS="-Wl,-O1 -Wl,--as-needed"
+DEB_COMPRESS_EXCLUDE = .c
+DEB_CONFIGURE_EXTRA_FLAGS := --enable-gtk-doc
+
+common-binary-predeb-arch:: list-missing
Modified: trunk/doc/reference/Makefile.am
==============================================================================
--- trunk/doc/reference/Makefile.am (original)
+++ trunk/doc/reference/Makefile.am Mon May 5 12:29:34 2008
@@ -38,7 +38,9 @@
# Extra options to supply to gtkdoc-fixref. Not normally needed.
# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html
-FIXXREF_OPTIONS=
+FIXXREF_OPTIONS=\
+ --extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/glib \
+ --extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/gobject
# Used for dependencies. The docs will be rebuilt if any of these change.
# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
@@ -48,7 +50,14 @@
# Header files to ignore when scanning.
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h
-IGNORE_HFILES=json-private.h json-marshal.h json-glib.h stamp-json-marshal.h
+IGNORE_HFILES=\
+ json-scanner.h \
+ json-private.h \
+ json-marshal.h \
+ json-glib.h \
+ json-enum-types.h \
+ stamp-json-enum-types.h \
+ stamp-json-marshal.h
EXTRA_HFILES=
@@ -58,8 +67,7 @@
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
-content_files= \
- version.xml
+content_files=version.xml
# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
# These files must be listed here *and* in content_files
Modified: trunk/doc/reference/json-glib-sections.txt
==============================================================================
--- trunk/doc/reference/json-glib-sections.txt (original)
+++ trunk/doc/reference/json-glib-sections.txt Mon May 5 12:29:34 2008
@@ -118,7 +118,6 @@
JSON_PARSER_GET_CLASS
<SUBSECTION Private>
-JsonTokenType
JsonParserPrivate
json_parser_get_type
json_parser_error_quark
Modified: trunk/json-glib/Makefile.am
==============================================================================
--- trunk/json-glib/Makefile.am (original)
+++ trunk/json-glib/Makefile.am Mon May 5 12:29:34 2008
@@ -16,11 +16,37 @@
$(JSON_DEBUG_CFLAGS) \
$(NULL)
-LDADD = $(JSON_LT_LDFLAGS) -export-dynamic -rpath $(libdir)
+LDADD = \
+ $(JSON_LT_LDFLAGS) \
+ -export-dynamic \
+ -export-symbols-regex "^json.*" \
+ -rpath $(libdir)
-BUILT_SOURCES = json-marshal.h json-marshal.c
+BUILT_SOURCES = json-marshal.h json-marshal.c json-enum-types.h json-enum-types.c
-STAMP_FILES = stamp-json-marshal.h
+STAMP_FILES = stamp-json-marshal.h stamp-json-enum-types.h
+
+source_h = \
+ $(top_srcdir)/json-glib/json-generator.h \
+ $(top_srcdir)/json-glib/json-gobject.h \
+ $(top_srcdir)/json-glib/json-parser.h \
+ $(top_srcdir)/json-glib/json-types.h \
+ $(top_srcdir)/json-glib/json-version.h \
+ $(NULL)
+
+source_h_private = \
+ $(top_srcdir)/json-glib/json-scanner.h \
+ $(NULL)
+
+source_c = \
+ json-array.c \
+ json-generator.c \
+ json-gobject.c \
+ json-node.c \
+ json-object.c \
+ json-parser.c \
+ json-scanner.c \
+ $(NULL)
json-marshal.h: stamp-json-marshal.h
@true
@@ -42,26 +68,24 @@
cp -f xgen-jmc json-marshal.c && \
rm -f xgen-jmc
-source_h = \
- $(top_srcdir)/json-glib/json-generator.h \
- $(top_srcdir)/json-glib/json-gobject.h \
- $(top_srcdir)/json-glib/json-parser.h \
- $(top_srcdir)/json-glib/json-scanner.h \
- $(top_srcdir)/json-glib/json-types.h \
- $(top_srcdir)/json-glib/json-version.h \
- $(NULL)
-
-source_h_private =
-
-source_c = \
- json-array.c \
- json-generator.c \
- json-gobject.c \
- json-node.c \
- json-object.c \
- json-parser.c \
- json-scanner.c \
- $(NULL)
+json-enum-types.h: stamp-json-enum-types.h
+ @true
+stamp-json-enum-types.h: $(source_h) Makefile
+ ( cd $(top_srcdir)/json-glib && \
+ $(GLIB_MKENUMS) \
+ --template $(top_srcdir)/json-glib/json-enum-types.h.in \
+ $(source_h) ) > xgen-ceth \
+ && (cmp xgen-ceth json-enum-types.h || cp xgen-ceth json-enum-types.h) \
+ && rm -f xgen-ceth \
+ && echo timestamp > $(@F)
+
+json-enum-types.c: json-enum-types.h
+ ( cd $(top_srcdir)/json-glib && \
+ $(GLIB_MKENUMS) \
+ --template $(top_srcdir)/json-glib/json-enum-types.c.in \
+ $(source_h) ) > xgen-cetc \
+ && cp xgen-cetc json-enum-types.c \
+ && rm -f xgen-cetc
lib_LTLIBRARIES = libjson-glib-1.0.la
@@ -77,12 +101,19 @@
jsonincludedir = $(includedir)/json-glib-1.0/json-glib
jsoninclude_DATA = \
$(source_h) \
+ $(top_srcdir)/json-glib/json-enum-types.h \
$(top_srcdir)/json-glib/json-glib.h
CLEANFILES = $(STAMP_FILES) $(BUILT_SOURCES)
DISTCLEANFILES = json-version.h
-EXTRA_DIST += json-version.h.in json-glib.h json-marshal.list
+EXTRA_DIST += \
+ json-version.h.in \
+ json-scanner.h \
+ json-glib.h \
+ json-marshal.list \
+ json-enum-types.h.in \
+ json-enum-types.c.in
TESTS_ENVIRONMENT = srcdir="$(srcdir)" json_all_c_sources="$(source_c)"
Added: trunk/json-glib/json-enum-types.c.in
==============================================================================
--- (empty file)
+++ trunk/json-glib/json-enum-types.c.in Mon May 5 12:29:34 2008
@@ -0,0 +1,31 @@
+/*** BEGIN file-header ***/
+#include "json-enum-types.h"
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+#include "@filename@"
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+ enum_name@_get_type(void) {
+ static GType etype = 0;
+ if (G_UNLIKELY (!etype))
+ {
+ const G Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+ etype = g_ type@_register_static (g_intern_static_string ("@EnumName@"), values);
+ }
+ return etype;
+}
+
+/*** END value-tail ***/
Added: trunk/json-glib/json-enum-types.h.in
==============================================================================
--- (empty file)
+++ trunk/json-glib/json-enum-types.h.in Mon May 5 12:29:34 2008
@@ -0,0 +1,26 @@
+/*** BEGIN file-header ***/
+#ifndef __JSON_ENUM_TYPES_H__
+#define __JSON_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* !__JSON_ENUM_TYPES_H__ */
+/*** END file-tail ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name _get_type (void) G_GNUC_CONST;
+#define JSON_TYPE_ ENUMSHORT@ (@enum_name _get_type())
+
+/*** END value-header ***/
+
Modified: trunk/json-glib/json-glib.h
==============================================================================
--- trunk/json-glib/json-glib.h (original)
+++ trunk/json-glib/json-glib.h Mon May 5 12:29:34 2008
@@ -6,5 +6,6 @@
#include <json-glib/json-generator.h>
#include <json-glib/json-parser.h>
#include <json-glib/json-version.h>
+#include <json-glib/json-enum-types.h>
#endif /* __JSON_GLIB_H__ */
Modified: trunk/json-glib/json-gobject.c
==============================================================================
--- trunk/json-glib/json-gobject.c (original)
+++ trunk/json-glib/json-gobject.c Mon May 5 12:29:34 2008
@@ -189,8 +189,7 @@
{
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 @@
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;
Modified: trunk/json-glib/json-node.c
==============================================================================
--- trunk/json-glib/json-node.c (original)
+++ trunk/json-glib/json-node.c Mon May 5 12:29:34 2008
@@ -36,8 +36,8 @@
* When parsing a JSON data stream you extract the root node and walk
* the node tree by retrieving the type of data contained inside the
* node with the %JSON_NODE_TYPE macro. If the node contains a fundamental
- * type you can retrieve a copy of the GValue holding it with the
- * json_node_get_value() function, and then use the GValue API to extract
+ * type you can retrieve a copy of the #GValue holding it with the
+ * json_node_get_value() function, and then use the #GValue API to extract
* the data; if the node contains a complex type you can retrieve the
* #JsonObject or the #JsonArray using json_node_get_object() or
* json_node_get_array() respectively, and then retrieve the nodes
@@ -136,17 +136,26 @@
switch (copy->type)
{
case JSON_NODE_OBJECT:
- copy->data.object = json_object_ref (node->data.object);
+ if (node->data.object)
+ copy->data.object = json_object_ref (node->data.object);
break;
+
case JSON_NODE_ARRAY:
- copy->data.array = json_array_ref (node->data.array);
+ if (node->data.array)
+ copy->data.array = json_array_ref (node->data.array);
break;
+
case JSON_NODE_VALUE:
- g_value_init (&(copy->data.value), G_VALUE_TYPE (&(node->data.value)));
- g_value_copy (&(node->data.value), &(copy->data.value));
+ if (G_VALUE_TYPE (&(node->data.value)) != G_TYPE_INVALID)
+ {
+ g_value_init (&(copy->data.value), G_VALUE_TYPE (&(node->data.value)));
+ g_value_copy (&(node->data.value), &(copy->data.value));
+ }
break;
+
case JSON_NODE_NULL:
break;
+
default:
g_assert_not_reached ();
}
@@ -339,7 +348,7 @@
g_return_if_fail (node != NULL);
g_return_if_fail (JSON_NODE_TYPE (node) == JSON_NODE_VALUE);
- if (G_VALUE_TYPE (&(node->data.value)) != 0)
+ if (G_VALUE_TYPE (&(node->data.value)) != G_TYPE_INVALID)
{
g_value_init (value, G_VALUE_TYPE (&(node->data.value)));
g_value_copy (&(node->data.value), value);
Modified: trunk/json-glib/json-scanner.h
==============================================================================
--- trunk/json-glib/json-scanner.h (original)
+++ trunk/json-glib/json-scanner.h Mon May 5 12:29:34 2008
@@ -10,7 +10,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
Modified: trunk/tests/test-parser.c
==============================================================================
--- trunk/tests/test-parser.c (original)
+++ trunk/tests/test-parser.c Mon May 5 12:29:34 2008
@@ -31,6 +31,8 @@
"[ [ false, true, 42 ], [ true, false, 3.14 ], \"test\" ]",
"[ true, { } ]",
"[ false, { \"test\" : 42 } ]",
+ "[ { \"test\" : 42 }, null ]",
+ "[ true, { \"test\" : 42 }, null ]",
"[ { \"channel\" : \"/meta/connect\" } ]"
};
@@ -50,10 +52,13 @@
"{ \"array\" : [ false, \"foo\" ], \"object\" : { \"foo\" : true } }"
};
-static const gchar *test_assignments[] = {
- "var test = [ false, false, true ]",
- "var test = [ true, 42 ];",
- "var test = { \"foo\" : false }"
+static const struct {
+ const gchar *str;
+ const gchar *var;
+} test_assignments[] = {
+ { "var foo = [ false, false, true ]", "foo" },
+ { "var bar = [ true, 42 ];", "bar" },
+ { "var baz = { \"foo\" : false }", "baz" }
};
static const struct
@@ -421,7 +426,7 @@
{
GError *error = NULL;
- if (!json_parser_load_from_data (parser, test_assignments[i], -1, &error))
+ if (!json_parser_load_from_data (parser, test_assignments[i].str, -1, &error))
{
if (g_test_verbose ())
g_print ("Error: %s\n", error->message);
@@ -436,9 +441,10 @@
if (g_test_verbose ())
g_print ("checking assignment...\n");
+
g_assert (json_parser_has_assignment (parser, &var) == TRUE);
g_assert (var != NULL);
-
+ g_assert_cmpstr (var, ==, test_assignments[i].var);
g_assert (NULL != json_parser_get_root (parser));
}
}
@@ -493,8 +499,12 @@
node = json_object_get_member (object, test_unicode[i].member);
g_assert_cmpint (JSON_NODE_TYPE (node), ==, JSON_NODE_VALUE);
+ if (g_test_verbose ())
+ g_print ("checking simple string equality...\n");
g_assert_cmpstr (json_node_get_string (node), ==, test_unicode[i].match);
+ if (g_test_verbose ())
+ g_print ("checking for valid UTF-8...\n");
g_assert (g_utf8_validate (json_node_get_string (node), -1, NULL));
}
}
Modified: trunk/tests/test-serialize-full.c
==============================================================================
--- trunk/tests/test-serialize-full.c (original)
+++ trunk/tests/test-serialize-full.c Mon May 5 12:29:34 2008
@@ -41,6 +41,7 @@
gchar *baz;
TestBoxed blah;
TestEnum meh;
+ gchar **mah;
};
struct _TestObjectClass
@@ -112,7 +113,8 @@
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 @@
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 @@
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 @@
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_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 @@
object->blah.bar = object->bar;
object->meh = TEST_ENUM_BAR;
+
+ object->mah = NULL;
}
static const gchar *var_test =
@@ -305,7 +321,8 @@
" \"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 @@
{
GObject *object;
GError *error;
+ gchar *str;
error = NULL;
object = json_construct_gobject (TEST_TYPE_OBJECT, var_test, -1, &error);
@@ -335,6 +353,13 @@
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);
}
Modified: trunk/tests/test-serialize-simple.c
==============================================================================
--- trunk/tests/test-serialize-simple.c (original)
+++ trunk/tests/test-serialize-simple.c Mon May 5 12:29:34 2008
@@ -142,7 +142,10 @@
data = json_serialize_gobject (G_OBJECT (obj), &len);
+ g_assert (data != NULL);
g_assert_cmpint (len, >, 0);
+ g_assert_cmpint (len, ==, strlen (data));
+
if (g_test_verbose ())
g_print ("TestObject:\n%s\n", data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]