[libsoup] Support g_autoptr() for all libsoup object types



commit 5df74a141a746d53162f3f10e6c468539ae2de13
Author: Kalev Lember <klember redhat com>
Date:   Tue Sep 8 12:37:33 2015 +0200

    Support g_autoptr() for all libsoup object types
    
    This allows using e.g. g_autoptr(SoupSession) in other programs, but
    does not make libsoup itself use g_autoptr, or require a new enough glib
    to support it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754721

 docs/reference/Makefile.am  |    2 +-
 libsoup/Makefile.am         |    1 +
 libsoup/soup-autocleanups.h |   47 +++++++++++++++++++++++++++++++++++++++++++
 libsoup/soup.h              |    1 +
 4 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 6011da1..71306f7 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -29,7 +29,7 @@ HFILE_GLOB=
 CFILE_GLOB=
 
 # Header files to ignore when scanning.
-IGNORE_HFILES= soup.h soup-enum-types.h \
+IGNORE_HFILES= soup.h soup-autocleanups.h soup-enum-types.h \
        soup-message-private.h soup-session-private.h \
        soup-auth-basic.h soup-auth-digest.h soup-auth-ntlm.h \
        soup-connection.h soup-connection-auth.h \
diff --git a/libsoup/Makefile.am b/libsoup/Makefile.am
index 1740f89..df25985 100644
--- a/libsoup/Makefile.am
+++ b/libsoup/Makefile.am
@@ -31,6 +31,7 @@ soup_headers =                        \
        soup-auth-domain-basic.h  \
        soup-auth-domain-digest.h \
        soup-auth-manager.h     \
+       soup-autocleanups.h     \
        soup-cache.h            \
        soup-content-decoder.h  \
        soup-content-sniffer.h  \
diff --git a/libsoup/soup-autocleanups.h b/libsoup/soup-autocleanups.h
new file mode 100644
index 0000000..f50a5cd
--- /dev/null
+++ b/libsoup/soup-autocleanups.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2015 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SOUP_AUTOCLEANUPS_H
+#define SOUP_AUTOCLEANUPS_H
+
+#include <libsoup/soup-types.h>
+
+#if SOUP_VERSION_MAX_ALLOWED >= SOUP_VERSION_2_52
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupAddress, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupAuth, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupAuthDomain, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupCookie, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupCookieJar, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupDate, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupMessage, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupRequest, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupRequestHTTP, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupServer, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSession, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSessionAsync, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSessionFeature, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSessionSync, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSocket, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupURI, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupWebsocketConnection, g_object_unref)
+
+#endif
+#endif
+
+#endif /* SOUP_AUTOCLEANUPS_H */
diff --git a/libsoup/soup.h b/libsoup/soup.h
index 7c5f1ba..9cc191a 100644
--- a/libsoup/soup.h
+++ b/libsoup/soup.h
@@ -16,6 +16,7 @@ extern "C" {
 #include <libsoup/soup-auth-domain-basic.h>
 #include <libsoup/soup-auth-domain-digest.h>
 #include <libsoup/soup-auth-manager.h>
+#include <libsoup/soup-autocleanups.h>
 #include <libsoup/soup-cache.h>
 #include <libsoup/soup-content-decoder.h>
 #include <libsoup/soup-content-sniffer.h>


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