[gnome-builder/wip/gtk4-port: 599/1774] plugins/autotools: port to libide-io




commit 7983e72daac0527511c8d089edf9ee504f5031db
Author: Christian Hergert <chergert redhat com>
Date:   Mon Apr 18 07:38:28 2022 -0700

    plugins/autotools: port to libide-io
    
    Now that we have the task cache again, we can port this away from using
    anything in libdazzle.

 src/plugins/autotools/ide-autotools-build-system.c |  9 +++--
 src/plugins/autotools/ide-makecache-target.c       | 11 ++----
 src/plugins/autotools/ide-makecache.c              | 44 ++++++++++------------
 3 files changed, 27 insertions(+), 37 deletions(-)
---
diff --git a/src/plugins/autotools/ide-autotools-build-system.c 
b/src/plugins/autotools/ide-autotools-build-system.c
index 8ab29a0ab..4daa8eceb 100644
--- a/src/plugins/autotools/ide-autotools-build-system.c
+++ b/src/plugins/autotools/ide-autotools-build-system.c
@@ -24,9 +24,10 @@
 
 #include <gio/gio.h>
 #include <gtksourceview/gtksource.h>
+#include <string.h>
+
 #include <libide-foundry.h>
 #include <libide-vcs.h>
-#include <string.h>
 
 #include "ide-autotools-build-system.h"
 #include "ide-autotools-makecache-stage.h"
@@ -74,8 +75,8 @@ is_configure (GFile *file)
   g_assert (G_IS_FILE (file));
 
   name = g_file_get_basename (file);
-  return dzl_str_equal0 (name, "configure.ac") ||
-         dzl_str_equal0 (name, "configure.in");
+  return ide_str_equal0 (name, "configure.ac") ||
+         ide_str_equal0 (name, "configure.in");
 }
 
 static gboolean
@@ -237,7 +238,7 @@ looks_like_makefile (IdeBuffer *buffer)
 
       lang_id = gtk_source_language_get_id (language);
 
-      if (dzl_str_equal0 (lang_id, "automake") || dzl_str_equal0 (lang_id, "makefile"))
+      if (ide_str_equal0 (lang_id, "automake") || ide_str_equal0 (lang_id, "makefile"))
         return TRUE;
     }
 
diff --git a/src/plugins/autotools/ide-makecache-target.c b/src/plugins/autotools/ide-makecache-target.c
index d60f03af4..456584bc8 100644
--- a/src/plugins/autotools/ide-makecache-target.c
+++ b/src/plugins/autotools/ide-makecache-target.c
@@ -20,16 +20,15 @@
 
 #define G_LOG_DOMAIN "ide-makecache-target"
 
-#include <dazzle.h>
+#include "config.h"
+
+#include <libide-io.h>
 
 #include "ide-makecache-target.h"
 
 G_DEFINE_BOXED_TYPE (IdeMakecacheTarget, ide_makecache_target,
                      ide_makecache_target_ref, ide_makecache_target_unref)
 
-DZL_DEFINE_COUNTER (instances, "IdeMakecacheTarget", "Instances",
-                    "Number of IdeMakecacheTarget instances.")
-
 struct _IdeMakecacheTarget
 {
   volatile gint  ref_count;
@@ -49,8 +48,6 @@ ide_makecache_target_unref (IdeMakecacheTarget *self)
       g_free (self->subdir);
       g_free (self->target);
       g_slice_free (IdeMakecacheTarget, self);
-
-      DZL_COUNTER_DEC (instances);
     }
 }
 
@@ -81,8 +78,6 @@ ide_makecache_target_new (const gchar *subdir,
   self->subdir = g_strdup (subdir);
   self->target = g_strdup (target);
 
-  DZL_COUNTER_INC (instances);
-
   return self;
 }
 
diff --git a/src/plugins/autotools/ide-makecache.c b/src/plugins/autotools/ide-makecache.c
index 58a8e4c41..ee535fe27 100644
--- a/src/plugins/autotools/ide-makecache.c
+++ b/src/plugins/autotools/ide-makecache.c
@@ -24,7 +24,6 @@
 #include "config.h"
 
 #include <ctype.h>
-#include <dazzle.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <gio/gio.h>
@@ -33,6 +32,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include <libide-io.h>
 #include <libide-foundry.h>
 #include <libide-vcs.h>
 
@@ -51,8 +51,8 @@ struct _IdeMakecache
 
   GFile        *parent;
   GMappedFile  *mapped;
-  DzlTaskCache *file_targets_cache;
-  DzlTaskCache *file_flags_cache;
+  IdeTaskCache *file_targets_cache;
+  IdeTaskCache *file_flags_cache;
   GPtrArray    *build_targets;
   IdeRuntime   *runtime;
   const gchar  *make_name;
@@ -84,8 +84,6 @@ typedef struct
 
 G_DEFINE_FINAL_TYPE (IdeMakecache, ide_makecache, IDE_TYPE_OBJECT)
 
-DZL_DEFINE_COUNTER (instances, "IdeMakecache", "Instances", "The number of IdeMakecache")
-
 static void
 get_build_targets_free (GetBuildTargets *data)
 {
@@ -641,7 +639,7 @@ ide_makecache_get_file_flags_worker (GTask        *task,
 
   IDE_ENTRY;
 
-  g_assert (DZL_IS_TASK_CACHE (source_object));
+  g_assert (IDE_IS_TASK_CACHE (source_object));
   g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
   g_assert (G_IS_TASK (task));
   g_assert (lookup != NULL);
@@ -830,7 +828,7 @@ ide_makecache_get_file_targets_worker (GTask        *task,
 
   IDE_ENTRY;
 
-  g_assert (DZL_IS_TASK_CACHE (source_object));
+  g_assert (IDE_IS_TASK_CACHE (source_object));
   g_assert (G_IS_TASK (task));
   g_assert (lookup != NULL);
   g_assert (lookup->mapped != NULL);
@@ -902,7 +900,7 @@ ide_makecache_get_file_targets_worker (GTask        *task,
 }
 
 static void
-ide_makecache_get_file_targets_dispatch (DzlTaskCache  *cache,
+ide_makecache_get_file_targets_dispatch (IdeTaskCache  *cache,
                                          gconstpointer  key,
                                          GTask         *task,
                                          gpointer       user_data)
@@ -911,7 +909,7 @@ ide_makecache_get_file_targets_dispatch (DzlTaskCache  *cache,
   FileTargetsLookup *lookup;
   GFile *file = (GFile *)key;
 
-  g_assert (DZL_IS_TASK_CACHE (cache));
+  g_assert (IDE_IS_TASK_CACHE (cache));
   g_assert (IDE_IS_MAKECACHE (self));
   g_assert (G_IS_FILE (file));
   g_assert (G_IS_TASK (task));
@@ -994,7 +992,7 @@ ide_makecache_get_file_flags__get_targets_cb (GObject      *object,
 }
 
 static void
-ide_makecache_get_file_flags_dispatch (DzlTaskCache  *cache,
+ide_makecache_get_file_flags_dispatch (IdeTaskCache  *cache,
                                        gconstpointer  key,
                                        GTask         *task,
                                        gpointer       user_data)
@@ -1051,8 +1049,6 @@ ide_makecache_finalize (GObject *object)
   g_clear_pointer (&self->build_targets, g_ptr_array_unref);
 
   G_OBJECT_CLASS (ide_makecache_parent_class)->finalize (object);
-
-  DZL_COUNTER_DEC (instances);
 }
 
 static void
@@ -1066,11 +1062,9 @@ ide_makecache_class_init (IdeMakecacheClass *klass)
 static void
 ide_makecache_init (IdeMakecache *self)
 {
-  DZL_COUNTER_INC (instances);
-
   self->make_name = "make";
 
-  self->file_targets_cache = dzl_task_cache_new ((GHashFunc)g_file_hash,
+  self->file_targets_cache = ide_task_cache_new ((GHashFunc)g_file_hash,
                                                  (GEqualFunc)g_file_equal,
                                                  g_object_ref,
                                                  g_object_unref,
@@ -1081,9 +1075,9 @@ ide_makecache_init (IdeMakecache *self)
                                                  self,
                                                  NULL);
 
-  dzl_task_cache_set_name (self->file_targets_cache, "makecache: file-targets-cache");
+  ide_task_cache_set_name (self->file_targets_cache, "makecache: file-targets-cache");
 
-  self->file_flags_cache = dzl_task_cache_new ((GHashFunc)g_file_hash,
+  self->file_flags_cache = ide_task_cache_new ((GHashFunc)g_file_hash,
                                                (GEqualFunc)g_file_equal,
                                                g_object_ref,
                                                g_object_unref,
@@ -1094,7 +1088,7 @@ ide_makecache_init (IdeMakecache *self)
                                                self,
                                                NULL);
 
-  dzl_task_cache_set_name (self->file_flags_cache, "makecache: file-flags-cache");
+  ide_task_cache_set_name (self->file_flags_cache, "makecache: file-flags-cache");
 }
 
 static void
@@ -1217,12 +1211,12 @@ ide_makecache_get_file_targets__task_cache_get_cb (GObject      *object,
                                                    GAsyncResult *result,
                                                    gpointer      user_data)
 {
-  DzlTaskCache *cache = (DzlTaskCache *)object;
+  IdeTaskCache *cache = (IdeTaskCache *)object;
   g_autoptr(GTask) task = user_data;
   g_autoptr(GError) error = NULL;
   GPtrArray *ret;
 
-  if (!(ret = dzl_task_cache_get_finish (cache, result, &error)))
+  if (!(ret = ide_task_cache_get_finish (cache, result, &error)))
     {
       g_assert (error != NULL);
       g_task_return_error (task, g_steal_pointer (&error));
@@ -1248,7 +1242,7 @@ ide_makecache_get_file_targets_async (IdeMakecache        *self,
 
   task = g_task_new (self, cancellable, callback, user_data);
 
-  dzl_task_cache_get_async (self->file_targets_cache,
+  ide_task_cache_get_async (self->file_targets_cache,
                             file,
                             FALSE,
                             cancellable,
@@ -1288,12 +1282,12 @@ ide_makecache_get_file_flags__task_cache_get_cb (GObject      *object,
                                                  GAsyncResult *result,
                                                  gpointer      user_data)
 {
-  DzlTaskCache *cache = (DzlTaskCache *)object;
+  IdeTaskCache *cache = (IdeTaskCache *)object;
   g_autoptr(GTask) task = user_data;
   g_autoptr(GError) error = NULL;
   gchar **ret;
 
-  if (!(ret = dzl_task_cache_get_finish (cache, result, &error)))
+  if (!(ret = ide_task_cache_get_finish (cache, result, &error)))
     {
       g_assert (error != NULL);
       g_task_return_error (task, g_steal_pointer (&error));
@@ -1319,7 +1313,7 @@ ide_makecache_get_file_flags_async (IdeMakecache        *self,
 
   task = g_task_new (self, cancellable, callback, user_data);
 
-  dzl_task_cache_get_async (self->file_flags_cache,
+  ide_task_cache_get_async (self->file_flags_cache,
                             file,
                             FALSE,
                             cancellable,
@@ -1452,7 +1446,7 @@ find_install_dir (const gchar *key,
   const gchar *path = NULL;
 
   if (g_str_has_prefix (key, "nodist_"))
-    key += DZL_LITERAL_LENGTH ("nodist_");
+    key += strlen ("nodist_");
 
   parts = g_strsplit (key, "_", 2);
   dirkey = parts[0];


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