[json-glib] Add autoptr macros



commit 130190ed1ca0387b4bc22b15b0e1a910e961c667
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Feb 29 00:27:59 2016 +0000

    Add autoptr macros
    
    GLib can take advantage of the "cleanup" attribute by using a bunch of
    macro magic. This has been slowly been used across various libraries in
    the G* stack, so JSON-GLib should provide symbols for the automatic
    memory management of its types.

 json-glib/json-builder.h   |    4 ++++
 json-glib/json-generator.h |    4 ++++
 json-glib/json-parser.h    |    4 ++++
 json-glib/json-path.h      |    4 ++++
 json-glib/json-reader.h    |    4 ++++
 json-glib/json-types.h     |    6 ++++++
 6 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/json-glib/json-builder.h b/json-glib/json-builder.h
index dd0bad8..45d4b5d 100644
--- a/json-glib/json-builder.h
+++ b/json-glib/json-builder.h
@@ -115,6 +115,10 @@ JsonBuilder *json_builder_add_string_value   (JsonBuilder  *builder,
 JSON_AVAILABLE_IN_1_0
 JsonBuilder *json_builder_add_null_value     (JsonBuilder  *builder);
 
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonBuilder, g_object_unref)
+#endif
+
 G_END_DECLS
 
 #endif /* __JSON_BUILDER_H__ */
diff --git a/json-glib/json-generator.h b/json-glib/json-generator.h
index 99c1b1d..194495a 100644
--- a/json-glib/json-generator.h
+++ b/json-glib/json-generator.h
@@ -115,6 +115,10 @@ gboolean        json_generator_to_stream        (JsonGenerator  *generator,
                                                  GCancellable   *cancellable,
                                                  GError        **error);
 
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonGenerator, g_object_unref)
+#endif
+
 G_END_DECLS
 
 #endif /* __JSON_GENERATOR_H__ */
diff --git a/json-glib/json-parser.h b/json-glib/json-parser.h
index 8666548..a65558e 100644
--- a/json-glib/json-parser.h
+++ b/json-glib/json-parser.h
@@ -183,6 +183,10 @@ JSON_AVAILABLE_IN_1_0
 gboolean    json_parser_has_assignment          (JsonParser           *parser,
                                                  gchar               **variable_name);
 
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonParser, g_object_unref)
+#endif
+
 G_END_DECLS
 
 #endif /* __JSON_PARSER_H__ */
diff --git a/json-glib/json-path.h b/json-glib/json-path.h
index b8ffb91..3c3ddf0 100644
--- a/json-glib/json-path.h
+++ b/json-glib/json-path.h
@@ -97,6 +97,10 @@ JsonNode *      json_path_query         (const char  *expression,
                                          JsonNode    *root,
                                          GError     **error);
 
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonPath, g_object_unref)
+#endif
+
 G_END_DECLS
 
 #endif /* __JSON_PATH_H__ */
diff --git a/json-glib/json-reader.h b/json-glib/json-reader.h
index 32e90da..786ed7b 100644
--- a/json-glib/json-reader.h
+++ b/json-glib/json-reader.h
@@ -166,6 +166,10 @@ gboolean               json_reader_get_boolean_value (JsonReader   *reader);
 JSON_AVAILABLE_IN_1_0
 gboolean               json_reader_get_null_value    (JsonReader   *reader);
 
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonReader, g_object_unref)
+#endif
+
 G_END_DECLS
 
 #endif /* __JSON_READER_H__ */
diff --git a/json-glib/json-types.h b/json-glib/json-types.h
index eea1613..1ee84ff 100644
--- a/json-glib/json-types.h
+++ b/json-glib/json-types.h
@@ -468,6 +468,12 @@ void                  json_array_foreach_element     (JsonArray   *array,
                                                       JsonArrayForeach func,
                                                       gpointer     data);
 
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonArray, json_array_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonObject, json_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (JsonNode, json_node_free)
+#endif
+
 G_END_DECLS
 
 #endif /* __JSON_TYPES_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]