[gom] tests: use G_ADD_PRIVATE for type definition



commit 1b8245d4f89464dfc72b6248ff120ac30e76d77b
Author: Victor Toso <me victortoso com>
Date:   Mon Feb 17 22:51:47 2020 +0100

    tests: use G_ADD_PRIVATE for type definition
    
    Removes several of the following:
     > ../tests/test-gom-transform.c:170:3: warning: ‘g_type_class_add_private’ is deprecated 
[-Wdeprecated-declarations]
     >   170 |   g_type_class_add_private(object_class, sizeof(ItemResourcePrivate));
     >       |   ^~~~~~~~~~~~~~~~~~~~~~~~

 tests/test-gom-constraints.c   |  7 ++-----
 tests/test-gom-datetime.c      |  7 ++-----
 tests/test-gom-find-specific.c |  7 ++-----
 tests/test-gom-find.c          |  7 ++-----
 tests/test-gom-insert.c        | 14 ++++----------
 tests/test-gom-migration.c     | 14 ++++----------
 tests/test-gom-sorting.c       |  7 ++-----
 tests/test-gom-stress.c        |  7 ++-----
 tests/test-gom-table-name.c    |  7 ++-----
 tests/test-gom-transform.c     |  7 ++-----
 tests/test-gom-update.c        |  7 ++-----
 11 files changed, 26 insertions(+), 65 deletions(-)
---
diff --git a/tests/test-gom-constraints.c b/tests/test-gom-constraints.c
index b421b24..d706a36 100644
--- a/tests/test-gom-constraints.c
+++ b/tests/test-gom-constraints.c
@@ -29,7 +29,7 @@ typedef struct {
 
 GType item_resource_get_type(void);
 
-G_DEFINE_TYPE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
 
 enum {
   PROP_0,
@@ -106,7 +106,6 @@ item_resource_class_init (ItemResourceClass *klass)
   object_class->get_property = item_resource_get_property;
   object_class->set_property = item_resource_set_property;
   object_class->finalize = item_resource_finalize;
-  g_type_class_add_private(object_class, sizeof(ItemResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, "items");
@@ -135,9 +134,7 @@ item_resource_class_init (ItemResourceClass *klass)
 static void
 item_resource_init (ItemResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               ITEM_TYPE_RESOURCE,
-                                               ItemResourcePrivate);
+  resource->priv = item_resource_get_instance_private(resource);
 }
 
 static void
diff --git a/tests/test-gom-datetime.c b/tests/test-gom-datetime.c
index 77ad4d3..bfca8b0 100644
--- a/tests/test-gom-datetime.c
+++ b/tests/test-gom-datetime.c
@@ -39,7 +39,7 @@ typedef struct {
 
 GType item_resource_get_type(void);
 
-G_DEFINE_TYPE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
 
 static GParamSpec *item_specs[LAST_PROP];
 
@@ -117,7 +117,6 @@ item_resource_class_init (ItemResourceClass *klass)
   object_class->finalize = item_resource_finalize;
   object_class->get_property = item_resource_get_property;
   object_class->set_property = item_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(ItemResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, "items");
@@ -151,9 +150,7 @@ item_resource_class_init (ItemResourceClass *klass)
 static void
 item_resource_init (ItemResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               ITEM_TYPE_RESOURCE,
-                                               ItemResourcePrivate);
+  resource->priv = item_resource_get_instance_private(resource);
 }
 
 static void
diff --git a/tests/test-gom-find-specific.c b/tests/test-gom-find-specific.c
index 35cfd13..267b143 100644
--- a/tests/test-gom-find-specific.c
+++ b/tests/test-gom-find-specific.c
@@ -42,7 +42,7 @@ typedef struct
 
 GType episode_resource_get_type(void);
 
-G_DEFINE_TYPE(EpisodeResource, episode_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(EpisodeResource, episode_resource, GOM_TYPE_RESOURCE)
 
 enum {
   PROP_0,
@@ -159,7 +159,6 @@ episode_resource_class_init (EpisodeResourceClass *klass)
   object_class->finalize = episode_resource_finalize;
   object_class->get_property = episode_resource_get_property;
   object_class->set_property = episode_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(EpisodeResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, "episodes");
@@ -209,9 +208,7 @@ episode_resource_class_init (EpisodeResourceClass *klass)
 static void
 episode_resource_init (EpisodeResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               EPISODE_TYPE_RESOURCE,
-                                               EpisodeResourcePrivate);
+  resource->priv = episode_resource_get_instance_private(resource);
 }
 
 static void
diff --git a/tests/test-gom-find.c b/tests/test-gom-find.c
index aed010e..4544d10 100644
--- a/tests/test-gom-find.c
+++ b/tests/test-gom-find.c
@@ -33,7 +33,7 @@ typedef struct {
 
 GType bookmarks_resource_get_type(void);
 
-G_DEFINE_TYPE(BookmarksResource, bookmarks_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(BookmarksResource, bookmarks_resource, GOM_TYPE_RESOURCE)
 
 enum {
   PROP_0,
@@ -130,7 +130,6 @@ bookmarks_resource_class_init (BookmarksResourceClass *klass)
   object_class->finalize = bookmarks_resource_finalize;
   object_class->get_property = bookmarks_resource_get_property;
   object_class->set_property = bookmarks_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(BookmarksResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, "bookmarks");
@@ -184,9 +183,7 @@ bookmarks_resource_class_init (BookmarksResourceClass *klass)
 static void
 bookmarks_resource_init (BookmarksResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               BOOKMARKS_TYPE_RESOURCE,
-                                               BookmarksResourcePrivate);
+  resource->priv = bookmarks_resource_get_instance_private(resource);
 }
 
 #if 0
diff --git a/tests/test-gom-insert.c b/tests/test-gom-insert.c
index 7b91f3c..26e0f93 100644
--- a/tests/test-gom-insert.c
+++ b/tests/test-gom-insert.c
@@ -37,7 +37,7 @@ typedef struct {
 
 GType item_resource_get_type(void);
 
-G_DEFINE_TYPE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
 
 static GParamSpec *item_specs[LAST_PROP];
 
@@ -109,7 +109,6 @@ item_resource_class_init (ItemResourceClass *klass)
   object_class->finalize = item_resource_finalize;
   object_class->get_property = item_resource_get_property;
   object_class->set_property = item_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(ItemResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, "items");
@@ -143,9 +142,7 @@ item_resource_class_init (ItemResourceClass *klass)
 static void
 item_resource_init (ItemResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               ITEM_TYPE_RESOURCE,
-                                               ItemResourcePrivate);
+  resource->priv = item_resource_get_instance_private(resource);
 }
 
 /* Item2Resource object */
@@ -174,7 +171,7 @@ typedef struct {
 
 GType item2_resource_get_type(void);
 
-G_DEFINE_TYPE(Item2Resource, item2_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(Item2Resource, item2_resource, GOM_TYPE_RESOURCE)
 
 static GParamSpec *item2_specs[LAST_PROP];
 
@@ -244,7 +241,6 @@ item2_resource_class_init (Item2ResourceClass *klass)
   object_class->finalize = item2_resource_finalize;
   object_class->get_property = item2_resource_get_property;
   object_class->set_property = item2_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(Item2ResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, "items");
@@ -278,9 +274,7 @@ item2_resource_class_init (Item2ResourceClass *klass)
 static void
 item2_resource_init (Item2Resource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               ITEM2_TYPE_RESOURCE,
-                                               Item2ResourcePrivate);
+  resource->priv = item2_resource_get_instance_private(resource);
 }
 
 static void
diff --git a/tests/test-gom-migration.c b/tests/test-gom-migration.c
index 2dea73b..4f0540d 100644
--- a/tests/test-gom-migration.c
+++ b/tests/test-gom-migration.c
@@ -48,7 +48,7 @@ struct _SeriesResourceClass
 
 GType series_resource_get_type (void);
 
-G_DEFINE_TYPE (SeriesResource, series_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE (SeriesResource, series_resource, GOM_TYPE_RESOURCE)
 
 enum {
   PROP_SERIES_0,
@@ -138,7 +138,6 @@ series_resource_class_init (SeriesResourceClass *klass)
   object_class->finalize = series_resource_finalize;
   object_class->get_property = series_resource_get_property;
   object_class->set_property = series_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(SeriesResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, SERIES_TABLE_NAME);
@@ -186,9 +185,7 @@ series_resource_class_init (SeriesResourceClass *klass)
 static void
 series_resource_init (SeriesResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               SERIES_TYPE_RESOURCE,
-                                               SeriesResourcePrivate);
+  resource->priv = series_resource_get_instance_private(resource);
 }
 
 /* BookmarksResource object */
@@ -219,7 +216,7 @@ typedef struct {
 
 GType bookmarks_resource_get_type(void);
 
-G_DEFINE_TYPE(BookmarksResource, bookmarks_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(BookmarksResource, bookmarks_resource, GOM_TYPE_RESOURCE)
 
 enum {
   PROP_0,
@@ -307,7 +304,6 @@ bookmarks_resource_class_init (BookmarksResourceClass *klass)
   object_class->finalize = bookmarks_resource_finalize;
   object_class->get_property = bookmarks_resource_get_property;
   object_class->set_property = bookmarks_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(BookmarksResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, "bookmarks");
@@ -351,9 +347,7 @@ bookmarks_resource_class_init (BookmarksResourceClass *klass)
 static void
 bookmarks_resource_init (BookmarksResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               BOOKMARKS_TYPE_RESOURCE,
-                                               BookmarksResourcePrivate);
+  resource->priv = bookmarks_resource_get_instance_private(resource);
 }
 
 #if 0
diff --git a/tests/test-gom-sorting.c b/tests/test-gom-sorting.c
index a20a368..250bc6f 100644
--- a/tests/test-gom-sorting.c
+++ b/tests/test-gom-sorting.c
@@ -34,7 +34,7 @@ typedef struct
 
 GType episode_resource_get_type(void);
 
-G_DEFINE_TYPE(EpisodeResource, episode_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(EpisodeResource, episode_resource, GOM_TYPE_RESOURCE)
 
 enum {
    PROP_0,
@@ -151,7 +151,6 @@ episode_resource_class_init (EpisodeResourceClass *klass)
    object_class->finalize = episode_resource_finalize;
    object_class->get_property = episode_resource_get_property;
    object_class->set_property = episode_resource_set_property;
-   g_type_class_add_private(object_class, sizeof(EpisodeResourcePrivate));
 
    resource_class = GOM_RESOURCE_CLASS(klass);
    gom_resource_class_set_table(resource_class, "episodes");
@@ -194,9 +193,7 @@ episode_resource_class_init (EpisodeResourceClass *klass)
 static void
 episode_resource_init (EpisodeResource *resource)
 {
-   resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                                EPISODE_TYPE_RESOURCE,
-                                                EpisodeResourcePrivate);
+   resource->priv = episode_resource_get_instance_private(resource);
 }
 
 static void
diff --git a/tests/test-gom-stress.c b/tests/test-gom-stress.c
index 3f62bca..f86b682 100644
--- a/tests/test-gom-stress.c
+++ b/tests/test-gom-stress.c
@@ -27,7 +27,7 @@ typedef struct {
 
 GType item_resource_get_type(void);
 
-G_DEFINE_TYPE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
 
 enum {
   PROP_0,
@@ -108,7 +108,6 @@ item_resource_class_init (ItemResourceClass *klass)
   object_class->finalize = item_resource_finalize;
   object_class->get_property = item_resource_get_property;
   object_class->set_property = item_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(ItemResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, "items");
@@ -142,9 +141,7 @@ item_resource_class_init (ItemResourceClass *klass)
 static void
 item_resource_init (ItemResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               ITEM_TYPE_RESOURCE,
-                                               ItemResourcePrivate);
+  resource->priv = item_resource_get_instance_private(resource);
 }
 
 static void
diff --git a/tests/test-gom-table-name.c b/tests/test-gom-table-name.c
index d17f661..8c4d1d8 100644
--- a/tests/test-gom-table-name.c
+++ b/tests/test-gom-table-name.c
@@ -33,7 +33,7 @@ typedef struct {
 
 GType item_resource_get_type(void);
 
-G_DEFINE_TYPE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
 
 static GParamSpec *item_specs[LAST_PROP];
 
@@ -103,7 +103,6 @@ item_resource_class_init (ItemResourceClass *klass)
   object_class->finalize = item_resource_finalize;
   object_class->get_property = item_resource_get_property;
   object_class->set_property = item_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(ItemResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   /* Invalid table name */
@@ -138,9 +137,7 @@ item_resource_class_init (ItemResourceClass *klass)
 static void
 item_resource_init (ItemResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               ITEM_TYPE_RESOURCE,
-                                               ItemResourcePrivate);
+  resource->priv = item_resource_get_instance_private(resource);
 }
 
 static void
diff --git a/tests/test-gom-transform.c b/tests/test-gom-transform.c
index 5a452ba..5ce9556 100644
--- a/tests/test-gom-transform.c
+++ b/tests/test-gom-transform.c
@@ -30,7 +30,7 @@ typedef struct {
 
 GType item_resource_get_type(void);
 
-G_DEFINE_TYPE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
 
 enum {
   PROP_0,
@@ -167,7 +167,6 @@ item_resource_class_init (ItemResourceClass *klass)
   object_class->finalize = item_resource_finalize;
   object_class->get_property = item_resource_get_property;
   object_class->set_property = item_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(ItemResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, "items");
@@ -218,9 +217,7 @@ item_resource_class_init (ItemResourceClass *klass)
 static void
 item_resource_init (ItemResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               ITEM_TYPE_RESOURCE,
-                                               ItemResourcePrivate);
+  resource->priv = item_resource_get_instance_private(resource);
 }
 
 static gboolean
diff --git a/tests/test-gom-update.c b/tests/test-gom-update.c
index 4b4065f..a7caf64 100644
--- a/tests/test-gom-update.c
+++ b/tests/test-gom-update.c
@@ -37,7 +37,7 @@ typedef struct {
 
 GType item_resource_get_type(void);
 
-G_DEFINE_TYPE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
+G_DEFINE_TYPE_WITH_PRIVATE(ItemResource, item_resource, GOM_TYPE_RESOURCE)
 
 static GParamSpec *item_specs[LAST_PROP];
 
@@ -109,7 +109,6 @@ item_resource_class_init (ItemResourceClass *klass)
   object_class->finalize = item_resource_finalize;
   object_class->get_property = item_resource_get_property;
   object_class->set_property = item_resource_set_property;
-  g_type_class_add_private(object_class, sizeof(ItemResourcePrivate));
 
   resource_class = GOM_RESOURCE_CLASS(klass);
   gom_resource_class_set_table(resource_class, "items");
@@ -143,9 +142,7 @@ item_resource_class_init (ItemResourceClass *klass)
 static void
 item_resource_init (ItemResource *resource)
 {
-  resource->priv = G_TYPE_INSTANCE_GET_PRIVATE(resource,
-                                               ITEM_TYPE_RESOURCE,
-                                               ItemResourcePrivate);
+  resource->priv = item_resource_get_instance_private(resource);
 }
 
 static void


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