summaryrefslogtreecommitdiff
path: root/json-glib/json-parser.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2013-07-11 17:04:13 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2013-07-20 11:11:51 +0100
commit3fd47359707dfc15277cef505d4008c10d8455e9 (patch)
tree36ff73b84f46ccaaf001d452bc369ea5fc5d7f4e /json-glib/json-parser.c
parenta9327484746820a5a2b8c1acf4a78470b004f0a0 (diff)
downloadjson-glib-3fd47359707dfc15277cef505d4008c10d8455e9.tar.gz
Use new macros when compiling against new GLib
If we're being compiled against a newer version of GLib, we should use the new macros that add instance private data. Since this is a stable branch, we cannot bump the GLib requirement; so we use version checks to conditionally compile the new code.
Diffstat (limited to 'json-glib/json-parser.c')
-rw-r--r--json-glib/json-parser.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/json-glib/json-parser.c b/json-glib/json-parser.c
index 593258c..1600e90 100644
--- a/json-glib/json-parser.c
+++ b/json-glib/json-parser.c
@@ -45,7 +45,11 @@
#include "json-parser.h"
#include "json-scanner.h"
-#define JSON_PARSER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), JSON_TYPE_PARSER, JsonParserPrivate))
+#if GLIB_CHECK_VERSION (2, 37, 3)
+# define JSON_PARSER_GET_PRIVATE(obj) ((JsonParserPrivate *) json_parser_get_instance_private ((JsonParser *) (obj)))
+#else
+# define JSON_PARSER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), JSON_TYPE_PARSER, JsonParserPrivate))
+#endif
struct _JsonParserPrivate
{
@@ -102,7 +106,11 @@ static guint parser_signals[LAST_SIGNAL] = { 0, };
G_DEFINE_QUARK (json-parser-error-quark, json_parser_error)
+#if GLIB_CHECK_VERSION (2, 37, 3)
+G_DEFINE_TYPE_WITH_PRIVATE (JsonParser, json_parser, G_TYPE_OBJECT)
+#else
G_DEFINE_TYPE (JsonParser, json_parser, G_TYPE_OBJECT)
+#endif
static guint json_parse_array (JsonParser *parser,
JsonScanner *scanner,
@@ -156,7 +164,9 @@ json_parser_class_init (JsonParserClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+#if !GLIB_CHECK_VERSION (2, 37, 3)
g_type_class_add_private (klass, sizeof (JsonParserPrivate));
+#endif
gobject_class->dispose = json_parser_dispose;
gobject_class->finalize = json_parser_finalize;