summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2023-03-17 16:13:50 -0700
committerChristian Hergert <chergert@redhat.com>2023-03-22 16:44:35 -0700
commited2239dcec0d38929813bd6d3295a5ee30c89ebd (patch)
tree68a3e30900bf8c258ee1310debed0661f50356a4
parent8485365a6f07968ec7ffb757a1f2995be0116920 (diff)
downloadlibpeas-ed2239dcec0d38929813bd6d3295a5ee30c89ebd.tar.gz
plugin-loader-c: modernize GType definition
No need for Private data, we can store it directly in the instance struct.
-rw-r--r--libpeas/peas-plugin-loader-c.c33
-rw-r--r--libpeas/peas-plugin-loader-c.h21
2 files changed, 15 insertions, 39 deletions
diff --git a/libpeas/peas-plugin-loader-c.c b/libpeas/peas-plugin-loader-c.c
index 8155245..2a7383d 100644
--- a/libpeas/peas-plugin-loader-c.c
+++ b/libpeas/peas-plugin-loader-c.c
@@ -31,18 +31,13 @@
#include "peas-object-module.h"
#include "peas-plugin-info-priv.h"
-typedef struct {
+struct _PeasPluginLoaderC {
+ PeasPluginLoader parent_instance;
GMutex lock;
-
GHashTable *loaded_plugins;
-} PeasPluginLoaderCPrivate;
-
-G_DEFINE_TYPE_WITH_PRIVATE (PeasPluginLoaderC,
- peas_plugin_loader_c,
- PEAS_TYPE_PLUGIN_LOADER)
+};
-#define GET_PRIV(o) \
- (peas_plugin_loader_c_get_instance_private (o))
+G_DEFINE_FINAL_TYPE (PeasPluginLoaderC, peas_plugin_loader_c, PEAS_TYPE_PLUGIN_LOADER)
static GQuark quark_extension_type = 0;
static const gchar *intern_plugin_info = NULL;
@@ -52,11 +47,10 @@ peas_plugin_loader_c_load (PeasPluginLoader *loader,
PeasPluginInfo *info)
{
PeasPluginLoaderC *cloader = PEAS_PLUGIN_LOADER_C (loader);
- PeasPluginLoaderCPrivate *priv = GET_PRIV (cloader);
- g_mutex_lock (&priv->lock);
+ g_mutex_lock (&cloader->lock);
- if (!g_hash_table_lookup_extended (priv->loaded_plugins,
+ if (!g_hash_table_lookup_extended (cloader->loaded_plugins,
info->filename,
NULL, (gpointer *) &info->loader_data))
{
@@ -84,11 +78,11 @@ peas_plugin_loader_c_load (PeasPluginLoader *loader,
if (!g_type_module_use (G_TYPE_MODULE (info->loader_data)))
g_clear_object (&info->loader_data);
- g_hash_table_insert (priv->loaded_plugins,
+ g_hash_table_insert (cloader->loaded_plugins,
g_strdup (info->filename), info->loader_data);
}
- g_mutex_unlock (&priv->lock);
+ g_mutex_unlock (&cloader->lock);
return info->loader_data != NULL;
}
@@ -164,12 +158,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
static void
peas_plugin_loader_c_init (PeasPluginLoaderC *cloader)
{
- PeasPluginLoaderCPrivate *priv = GET_PRIV (cloader);
-
- g_mutex_init (&priv->lock);
+ g_mutex_init (&cloader->lock);
/* loaded_plugins maps PeasPluginInfo:filename to a PeasObjectModule */
- priv->loaded_plugins = g_hash_table_new_full (g_str_hash, g_str_equal,
+ cloader->loaded_plugins = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
}
@@ -177,11 +169,10 @@ static void
peas_plugin_loader_c_finalize (GObject *object)
{
PeasPluginLoaderC *cloader = PEAS_PLUGIN_LOADER_C (object);
- PeasPluginLoaderCPrivate *priv = GET_PRIV (cloader);
- g_mutex_clear (&priv->lock);
+ g_mutex_clear (&cloader->lock);
- g_hash_table_destroy (priv->loaded_plugins);
+ g_hash_table_destroy (cloader->loaded_plugins);
G_OBJECT_CLASS (peas_plugin_loader_c_parent_class)->finalize (object);
}
diff --git a/libpeas/peas-plugin-loader-c.h b/libpeas/peas-plugin-loader-c.h
index d326c6d..2c9e9a8 100644
--- a/libpeas/peas-plugin-loader-c.h
+++ b/libpeas/peas-plugin-loader-c.h
@@ -27,25 +27,10 @@
G_BEGIN_DECLS
-#define PEAS_TYPE_PLUGIN_LOADER_C (peas_plugin_loader_c_get_type ())
-#define PEAS_PLUGIN_LOADER_C(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PEAS_TYPE_PLUGIN_LOADER_C, PeasPluginLoaderC))
-#define PEAS_PLUGIN_LOADER_C_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PEAS_TYPE_PLUGIN_LOADER_C, PeasPluginLoaderCClass))
-#define PEAS_IS_PLUGIN_LOADER_C(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PEAS_TYPE_PLUGIN_LOADER_C))
-#define PEAS_IS_PLUGIN_LOADER_C_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PEAS_TYPE_PLUGIN_LOADER_C))
-#define PEAS_PLUGIN_LOADER_C_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PEAS_TYPE_PLUGIN_LOADER_C, PeasPluginLoaderCClass))
+#define PEAS_TYPE_PLUGIN_LOADER_C (peas_plugin_loader_c_get_type())
-typedef struct _PeasPluginLoaderC PeasPluginLoaderC;
-typedef struct _PeasPluginLoaderCClass PeasPluginLoaderCClass;
+G_DECLARE_FINAL_TYPE (PeasPluginLoaderC, peas_plugin_loader_c, PEAS, PLUGIN_LOADER_C, PeasPluginLoader)
-struct _PeasPluginLoaderC {
- PeasPluginLoader parent;
-};
-
-struct _PeasPluginLoaderCClass {
- PeasPluginLoaderClass parent_class;
-};
-
-GType peas_plugin_loader_c_get_type (void) G_GNUC_CONST;
-PeasPluginLoader *peas_plugin_loader_c_new (void);
+PeasPluginLoader *peas_plugin_loader_c_new (void);
G_END_DECLS