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



commit 2e4d297d21d3e3a494d986da0951e97397b5ae0c
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Mar 12 14:52:43 2015 +0100

    Support g_autoptr() for all gom object types
    
    This allows you to use e.g. g_autoptr(GomResource) in your code, but
    does not make gom itself use g_autoptr, or require a new enough glib
    to support it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746095

 gom/Makefile.include   |    1 +
 gom/gom-autocleanups.h |   40 ++++++++++++++++++++++++++++++++++++++++
 gom/gom.h              |    2 ++
 3 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/gom/Makefile.include b/gom/Makefile.include
index 2862b8c..eeb2162 100644
--- a/gom/Makefile.include
+++ b/gom/Makefile.include
@@ -15,6 +15,7 @@ INST_H_FILES += gom/gom-filter.h
 INST_H_FILES += gom/gom-repository.h
 INST_H_FILES += gom/gom-resource-group.h
 INST_H_FILES += gom/gom-resource.h
+INST_H_FILES += gom/gom-autocleanups.h
 
 NOINST_H_FILES = gom/gom-resource-priv.h
 
diff --git a/gom/gom-autocleanups.h b/gom/gom-autocleanups.h
new file mode 100644
index 0000000..c0fc1be
--- /dev/null
+++ b/gom/gom-autocleanups.h
@@ -0,0 +1,40 @@
+/* gom-adapter.h
+ *
+ * Copyright (C) 2015 Alexander Larsson <alexl redhat com>
+ *
+ * This file 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.1 of the License, or (at your option) any later version.
+ *
+ * This file 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 General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GOM_AUTOCLEANUPS_H
+#define GOM_AUTOCLEANUPS_H
+
+/* We need all the types, so don't try to include this directly */
+#if !defined (GOM_INSIDE)
+#error "Include <gom.h> instead of gom-autocleanups.h."
+#endif
+
+#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GomAdapter, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GomCommand, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GomCommandBuilder, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GomCursor, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GomFilter, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GomRepository, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GomResource, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GomResourceGroup, g_object_unref)
+
+#endif
+
+#endif /* GOM_AUTOCLEANUP_H */
diff --git a/gom/gom.h b/gom/gom.h
index 35bfb6e..9b67da7 100644
--- a/gom/gom.h
+++ b/gom/gom.h
@@ -35,6 +35,8 @@ G_BEGIN_DECLS
 #include "gom-resource-group.h"
 #include "gom-resource.h"
 
+#include "gom-autocleanups.h"
+
 #undef GOM_INSIDE
 
 G_END_DECLS


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