diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2013-07-11 17:04:13 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2013-07-20 11:11:51 +0100 |
commit | 3fd47359707dfc15277cef505d4008c10d8455e9 (patch) | |
tree | 36ff73b84f46ccaaf001d452bc369ea5fc5d7f4e /json-glib/json-builder.c | |
parent | a9327484746820a5a2b8c1acf4a78470b004f0a0 (diff) | |
download | json-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-builder.c')
-rw-r--r-- | json-glib/json-builder.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/json-glib/json-builder.c b/json-glib/json-builder.c index d2f5391..82e3ec7 100644 --- a/json-glib/json-builder.c +++ b/json-glib/json-builder.c @@ -48,8 +48,11 @@ #include "json-builder.h" -#define JSON_BUILDER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), JSON_TYPE_BUILDER, JsonBuilderPrivate)) +#if GLIB_CHECK_VERSION (2, 37, 3) +# define JSON_BUILDER_GET_PRIVATE(obj) ((JsonBuilderPrivate *) json_builder_get_instance_private ((JsonBuilder *) (obj))) +#else +# define JSON_BUILDER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), JSON_TYPE_BUILDER, JsonBuilderPrivate)) +#endif struct _JsonBuilderPrivate { @@ -104,7 +107,11 @@ json_builder_state_free (JsonBuilderState *state) } } -G_DEFINE_TYPE (JsonBuilder, json_builder, G_TYPE_OBJECT); +#if GLIB_CHECK_VERSION (2, 37, 3) +G_DEFINE_TYPE_WITH_PRIVATE (JsonBuilder, json_builder, G_TYPE_OBJECT) +#else +G_DEFINE_TYPE (JsonBuilder, json_builder, G_TYPE_OBJECT) +#endif static void json_builder_free_all_state (JsonBuilder *builder) @@ -142,7 +149,9 @@ json_builder_class_init (JsonBuilderClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); +#if !GLIB_CHECK_VERSION (2, 37, 3) g_type_class_add_private (klass, sizeof (JsonBuilderPrivate)); +#endif gobject_class->finalize = json_builder_finalize; } |