From b0af45d6b301b342fd1473962133cebf6d0ff1a0 Mon Sep 17 00:00:00 2001 From: Yi-Soo An Date: Wed, 11 Jul 2018 14:28:57 +0900 Subject: [PATCH 1/8] media: Add G_DEFINE_AUTOPTR_CLEANUP_FUNC To support g_autoptr, it is added. --- src/data/grl-media.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/grl-media.h b/src/data/grl-media.h index 1ce4653..8392e41 100644 --- a/src/data/grl-media.h +++ b/src/data/grl-media.h @@ -81,6 +81,8 @@ typedef struct _GrlMedia GrlMedia; typedef struct _GrlMediaPrivate GrlMediaPrivate; typedef struct _GrlMediaClass GrlMediaClass; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GrlMedia, g_object_unref) + struct _GrlMedia { GrlData parent; -- GitLab From 41fc4836836fd85457c79e1044780415e5f96410 Mon Sep 17 00:00:00 2001 From: Yi-Soo An Date: Wed, 11 Jul 2018 14:33:44 +0900 Subject: [PATCH 2/8] operation-options: Add G_DEFINE_AUTOPTR_CLEANUP_FUNC To support g_autoptr, it is added. --- src/grl-operation-options.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/grl-operation-options.h b/src/grl-operation-options.h index 5e4ef60..a6c3ee9 100644 --- a/src/grl-operation-options.h +++ b/src/grl-operation-options.h @@ -56,6 +56,8 @@ typedef struct { gpointer _grl_reserved[GRL_PADDING]; } GrlOperationOptionsClass; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GrlOperationOptions, g_object_unref) + #define GRL_TYPE_OPERATION_OPTIONS (grl_operation_options_get_type ()) #define GRL_OPERATION_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRL_TYPE_OPERATION_OPTIONS, GrlOperationOptions)) #define GRL_OPERATION_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRL_TYPE_OPERATION_OPTIONS, GrlOperationOptionsClass)) -- GitLab From 89fba3fdfc27a565fad8cceb6fae5a256ef81569 Mon Sep 17 00:00:00 2001 From: Yi-Soo An Date: Wed, 11 Jul 2018 14:57:35 +0900 Subject: [PATCH 3/8] data: Add G_DEFINE_AUTOPTR_CLEANUP_FUNC To support g_autoptr, it is added. https://gitlab.gnome.org/GNOME/grilo/merge_requests/10 --- src/data/grl-data.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/grl-data.h b/src/data/grl-data.h index be61b56..ae95d99 100644 --- a/src/data/grl-data.h +++ b/src/data/grl-data.h @@ -66,6 +66,8 @@ typedef struct _GrlData GrlData; typedef struct _GrlDataClass GrlDataClass; typedef struct _GrlDataPrivate GrlDataPrivate; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GrlData, g_object_unref) + struct _GrlData { GObject parent; -- GitLab From e3003601b107bed9a1f416462e0340c75090a083 Mon Sep 17 00:00:00 2001 From: Yi-Soo An Date: Wed, 11 Jul 2018 15:00:54 +0900 Subject: [PATCH 4/8] related-keys: Add G_DEFINE_AUTOPTR_CLEANUP_FUNC To support g_autoptr, it is added. https://gitlab.gnome.org/GNOME/grilo/merge_requests/10 --- src/data/grl-related-keys.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/grl-related-keys.h b/src/data/grl-related-keys.h index 5fb200a..c370bb6 100644 --- a/src/data/grl-related-keys.h +++ b/src/data/grl-related-keys.h @@ -65,6 +65,8 @@ typedef struct _GrlRelatedKeys GrlRelatedKeys; typedef struct _GrlRelatedKeysPrivate GrlRelatedKeysPrivate; typedef struct _GrlRelatedKeysClass GrlRelatedKeysClass; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GrlRelatedKeys, g_object_unref) + struct _GrlRelatedKeys { GObject parent; -- GitLab From 3b0fcdf8534a95de24f5c80349042fca63a6578b Mon Sep 17 00:00:00 2001 From: Yi-Soo An Date: Thu, 12 Jul 2018 14:12:26 +0900 Subject: [PATCH 5/8] caps: Add G_DEFINE_AUTOPTR_CLEANUP_FUNC To support g_autoptr, it is added. https://gitlab.gnome.org/GNOME/grilo/merge_requests/10 --- src/grl-caps.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/grl-caps.h b/src/grl-caps.h index 8dbdbdc..87db7db 100644 --- a/src/grl-caps.h +++ b/src/grl-caps.h @@ -57,6 +57,8 @@ typedef struct { gpointer _grl_reserved[GRL_PADDING]; } GrlCapsClass; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GrlCaps, g_object_unref) + #define GRL_TYPE_CAPS (grl_caps_get_type ()) #define GRL_CAPS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRL_TYPE_CAPS, GrlCaps)) #define GRL_CAPS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRL_TYPE_CAPS, GrlCapsClass)) -- GitLab From 38fd0dd7fb4dabd392d96406df13608db1a41490 Mon Sep 17 00:00:00 2001 From: Yi-Soo An Date: Thu, 12 Jul 2018 15:31:45 +0900 Subject: [PATCH 6/8] plugin: Add G_DEFINE_AUTOPTR_CLEANUP_FUNC To support g_autoptr, it is added. https://gitlab.gnome.org/GNOME/grilo/merge_requests/10 --- src/grl-plugin.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/grl-plugin.h b/src/grl-plugin.h index 5273d6e..ee81bcd 100644 --- a/src/grl-plugin.h +++ b/src/grl-plugin.h @@ -75,6 +75,8 @@ typedef struct _GrlPlugin GrlPlugin; typedef struct _GrlPluginPrivate GrlPluginPrivate; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GrlPlugin, g_object_unref) + struct _GrlPlugin { GObject parent; -- GitLab From 4b1706c386d372f3c1f2f6c14e8e5ac239e25e34 Mon Sep 17 00:00:00 2001 From: Yi-Soo An Date: Thu, 12 Jul 2018 16:41:06 +0900 Subject: [PATCH 7/8] net-wc: Add G_DEFINE_AUTOPTR_CLEANUP_FUNC To support g_autoptr, it is added. https://gitlab.gnome.org/GNOME/grilo/merge_requests/10 --- libs/net/grl-net-wc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/net/grl-net-wc.h b/libs/net/grl-net-wc.h index 00866bd..e8da707 100644 --- a/libs/net/grl-net-wc.h +++ b/libs/net/grl-net-wc.h @@ -86,6 +86,8 @@ typedef struct _GrlNetWc GrlNetWc; typedef struct _GrlNetWcClass GrlNetWcClass; typedef struct _GrlNetWcPrivate GrlNetWcPrivate; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GrlNetWc, g_object_unref) + /** * GrlNetWc: * @parent: the parent object struct -- GitLab From b5fc8bcc70ab94073b618516507375bfe1945395 Mon Sep 17 00:00:00 2001 From: Yi-Soo An Date: Thu, 12 Jul 2018 16:52:12 +0900 Subject: [PATCH 8/8] tests: Add g_autoptr tests The tests are for the classes - GrlNetWc - GrlData - GrlMedia - GrlRelatedKeys - GrlCaps - GrlOperationOptions - GrlPlugin https://gitlab.gnome.org/GNOME/grilo/merge_requests/10 --- tests/Makefile.am | 4 ++ tests/autoptr.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 tests/autoptr.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 01f01b3..4df8cbc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -20,6 +20,10 @@ TEST_PROGS = registry registry_SOURCES = registry.c registry_LDADD = $(progs_ldadd) +TEST_PROGS += autoptr +autoptr_SOURCES = autoptr.c +autoptr_LDADD = $(progs_ldadd) + if BUILD_GRILO_NET TEST_PROGS += lib-net lib_net_SOURCES = lib-net.c diff --git a/tests/autoptr.c b/tests/autoptr.c new file mode 100644 index 0000000..faef432 --- /dev/null +++ b/tests/autoptr.c @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2018 Yi-Soo An + * + * 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; version 2.1 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, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +/* + * This code is based on glib/tests/autoptr.c + */ + +#include + +#include +#include + +static void +test_grl_net_wc (void) +{ + g_autoptr (GrlNetWc) val = grl_net_wc_new (); + g_assert_nonnull (val); +} + +static void +test_grl_data (void) +{ + g_autoptr (GrlData) val = grl_data_new (); + g_assert_nonnull (val); +} + +static void +test_grl_related_keys (void) +{ + g_autoptr (GrlRelatedKeys) val = grl_related_keys_new (); + g_assert_nonnull (val); +} + +static void +test_grl_media (void) +{ + g_autoptr (GrlMedia) val = grl_media_new (); + g_assert_nonnull (val); +} + +static void +test_grl_caps (void) +{ + g_autoptr (GrlCaps) val = grl_caps_new (); + g_assert_nonnull (val); +} + +static void +test_grl_operation_options (void) +{ + g_autoptr (GrlOperationOptions) val = grl_operation_options_new (NULL); + g_assert_nonnull (val); +} + +static void +test_grl_plugin (void) +{ + g_autoptr (GrlPlugin) val = NULL; + + val = GRL_PLUGIN (g_object_new (GRL_TYPE_PLUGIN, NULL)); + + g_assert_nonnull (val); +} + +int +main (int argc, + char *argv[]) +{ + g_test_init (&argc, &argv, NULL); + + grl_init (&argc, &argv); + + g_test_add_func ("/autoptr/grl_net_wc", test_grl_net_wc); + + g_test_add_func ("/autoptr/grl_data", test_grl_data); + g_test_add_func ("/autoptr/grl_media", test_grl_media); + g_test_add_func ("/autoptr/grl_related_keys", test_grl_related_keys); + + g_test_add_func ("/autoptr/grl_caps", test_grl_caps); + g_test_add_func ("/autoptr/grl_operation_options", test_grl_operation_options); + g_test_add_func ("/autoptr/grl_plugin", test_grl_plugin); + + return g_test_run (); +} -- GitLab