[libsecret/wip/nielsdg/g-autoptr-support] Add support for g_autoptr() to our types



commit 88634273d43b0a45cac16d58df851412f624881d
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sat Jan 19 11:57:22 2019 +0100

    Add support for g_autoptr() to our types
    
    g_autoptr() is a macro that was defined in GLib 2.44 that allows for
    basic auto-cleanup of variables. One way to add this kind of support
    would be through the use of e.g. `G_DECLARE_DERIVABLE_TYPE()` for our
    declarations, but this would consitute an ABI break (due to the
    `...Private *` field in the public structs). Instead, we can use
    `G_DEFINE_AUTOPTR_CLEANUP_FUNC` to manually declare this.
    
    This commit also bumps the minimally required GLib version to 2.44

 configure.ac                  | 6 +++---
 libsecret/secret-collection.h | 2 ++
 libsecret/secret-item.h       | 2 ++
 libsecret/secret-prompt.h     | 2 ++
 libsecret/secret-schema.h     | 2 ++
 libsecret/secret-service.h    | 2 ++
 libsecret/secret-value.h      | 2 ++
 7 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 09080e0..b1e6bcc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,9 +9,9 @@ dnl Dependency versions
 
 # Required
 
-GLIB_REQ=2.38.0
-GLIB_MIN=GLIB_VERSION_2_38
-GLIB_MAX=GLIB_VERSION_2_38
+GLIB_REQ=2.44.0
+GLIB_MIN=GLIB_VERSION_2_44
+GLIB_MAX=GLIB_VERSION_2_44
 
 # Optional
 
diff --git a/libsecret/secret-collection.h b/libsecret/secret-collection.h
index 55530f6..14d7d5f 100644
--- a/libsecret/secret-collection.h
+++ b/libsecret/secret-collection.h
@@ -173,6 +173,8 @@ guint64             secret_collection_get_created              (SecretCollection
 
 guint64             secret_collection_get_modified             (SecretCollection *self);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretCollection, g_object_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_COLLECTION_H___ */
diff --git a/libsecret/secret-item.h b/libsecret/secret-item.h
index e02c871..2742720 100644
--- a/libsecret/secret-item.h
+++ b/libsecret/secret-item.h
@@ -191,6 +191,8 @@ guint64             secret_item_get_created                (SecretItem *self);
 
 guint64             secret_item_get_modified               (SecretItem *self);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretItem, g_object_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_ITEM_H___ */
diff --git a/libsecret/secret-prompt.h b/libsecret/secret-prompt.h
index 983c741..a8d1313 100644
--- a/libsecret/secret-prompt.h
+++ b/libsecret/secret-prompt.h
@@ -75,6 +75,8 @@ GVariant *          secret_prompt_perform_finish            (SecretPrompt *self,
                                                              GAsyncResult *result,
                                                              GError **error);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretPrompt, g_object_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_PROMPT_H___ */
diff --git a/libsecret/secret-schema.h b/libsecret/secret-schema.h
index 4039bd3..cd539a1 100644
--- a/libsecret/secret-schema.h
+++ b/libsecret/secret-schema.h
@@ -72,6 +72,8 @@ void              secret_schema_unref              (SecretSchema *schema);
 
 GType             secret_schema_attribute_get_type (void) G_GNUC_CONST;
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretSchema, g_object_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_SCHEMA_H___ */
diff --git a/libsecret/secret-service.h b/libsecret/secret-service.h
index e35f415..0e39186 100644
--- a/libsecret/secret-service.h
+++ b/libsecret/secret-service.h
@@ -304,6 +304,8 @@ gboolean             secret_service_set_alias_sync                (SecretService
                                                                    GCancellable *cancellable,
                                                                    GError **error);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretService, g_object_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_SERVICE_H___ */
diff --git a/libsecret/secret-value.h b/libsecret/secret-value.h
index baaff34..a36751e 100644
--- a/libsecret/secret-value.h
+++ b/libsecret/secret-value.h
@@ -51,6 +51,8 @@ SecretValue *       secret_value_ref               (SecretValue *value);
 
 void                secret_value_unref             (gpointer value);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretValue, secret_value_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_VALUE_H___ */


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