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-generator.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-generator.c')
| -rw-r--r-- | json-glib/json-generator.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/json-glib/json-generator.c b/json-glib/json-generator.c index 097f2a9..04beaf4 100644 --- a/json-glib/json-generator.c +++ b/json-glib/json-generator.c @@ -41,8 +41,11 @@ #include "json-marshal.h" #include "json-generator.h" -#define JSON_GENERATOR_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), JSON_TYPE_GENERATOR, JsonGeneratorPrivate)) +#if GLIB_CHECK_VERSION (2, 37, 3) +# define JSON_GENERATOR_GET_PRIVATE(obj) ((JsonGeneratorPrivate *) json_generator_get_instance_private ((JsonGenerator *) (obj))) +#else +# define JSON_GENERATOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), JSON_TYPE_GENERATOR, JsonGeneratorPrivate)) +#endif struct _JsonGeneratorPrivate { @@ -109,7 +112,11 @@ static const char json_exceptions[] = { static GParamSpec *generator_props[PROP_LAST] = { NULL, }; -G_DEFINE_TYPE (JsonGenerator, json_generator, G_TYPE_OBJECT); +#if GLIB_CHECK_VERSION (2, 37, 3) +G_DEFINE_TYPE_WITH_PRIVATE (JsonGenerator, json_generator, G_TYPE_OBJECT) +#else +G_DEFINE_TYPE (JsonGenerator, json_generator, G_TYPE_OBJECT) +#endif static gchar * json_strescape (const gchar *str) @@ -193,7 +200,9 @@ json_generator_class_init (JsonGeneratorClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); +#if !GLIB_CHECK_VERSION (2, 37, 3) g_type_class_add_private (klass, sizeof (JsonGeneratorPrivate)); +#endif /** * JsonGenerator:pretty: |
