summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2023-03-16 18:29:29 -0700
committerChristian Hergert <chergert@redhat.com>2023-03-22 16:44:35 -0700
commit3f9a89a8201f7ac7c53e53ab9d049c723997820c (patch)
tree64223707c3f0ef727df8aeed8733c477600e20ed
parent13d5b5a2a525e3fc351ec2bb742606de2b28291a (diff)
downloadlibpeas-3f9a89a8201f7ac7c53e53ab9d049c723997820c.tar.gz
janitorial: modernize PeasObjectModule
Use the modern GObject macros and remove autocleanups now that they are no longer necessary to be defined externally.
-rw-r--r--libpeas/libpeas.h1
-rw-r--r--libpeas/meson.build1
-rw-r--r--libpeas/peas-autocleanups.h42
-rw-r--r--libpeas/peas-object-module.c37
-rw-r--r--libpeas/peas-object-module.h31
5 files changed, 22 insertions, 90 deletions
diff --git a/libpeas/libpeas.h b/libpeas/libpeas.h
index de7f389..5508f89 100644
--- a/libpeas/libpeas.h
+++ b/libpeas/libpeas.h
@@ -22,7 +22,6 @@
#pragma once
#define LIBPEAS_INSIDE
-# include "peas-autocleanups.h"
# include "peas-engine.h"
# include "peas-extension.h"
# include "peas-extension-base.h"
diff --git a/libpeas/meson.build b/libpeas/meson.build
index b20caf2..ec6be40 100644
--- a/libpeas/meson.build
+++ b/libpeas/meson.build
@@ -14,7 +14,6 @@ peas_version_h = configure_file(
)
libpeas_public_h = files(
- 'peas-autocleanups.h',
'peas-engine.h',
'peas-extension.h',
'peas-extension-base.h',
diff --git a/libpeas/peas-autocleanups.h b/libpeas/peas-autocleanups.h
deleted file mode 100644
index 6dae77b..0000000
--- a/libpeas/peas-autocleanups.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * peas-autocleanups.h
- * This file is part of libpeas
- *
- * Copyright (C) 2015 - Garrett Regier
- *
- * libpeas 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.
- *
- * libpeas 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.
- *
- * SPDX-License-Identifier: LGPL-2.1-or-later
- */
-
-#pragma once
-
-#include "peas-engine.h"
-#include "peas-extension.h"
-#include "peas-extension-base.h"
-#include "peas-extension-set.h"
-#include "peas-object-module.h"
-
-G_BEGIN_DECLS
-
-#ifndef __GI_SCANNER__
-#if GLIB_CHECK_VERSION (2, 44, 0)
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (PeasObjectModule, g_object_unref)
-
-#endif /* GLIB_CHECK_VERSION (2, 44, 0) */
-#endif /* __GI_SCANNER__ */
-
-G_END_DECLS
diff --git a/libpeas/peas-object-module.c b/libpeas/peas-object-module.c
index 8b5c050..c43215e 100644
--- a/libpeas/peas-object-module.c
+++ b/libpeas/peas-object-module.c
@@ -67,7 +67,7 @@ typedef struct {
GDestroyNotify destroy_func;
} ExtensionImplementation;
-struct _PeasObjectModulePrivate {
+typedef struct _PeasObjectModulePrivate {
GModule *library;
PeasObjectModuleRegisterFunc register_func;
@@ -79,14 +79,9 @@ struct _PeasObjectModulePrivate {
guint resident : 1;
guint local_linkage : 1;
-};
-
-G_DEFINE_TYPE_WITH_PRIVATE (PeasObjectModule,
- peas_object_module,
- G_TYPE_TYPE_MODULE)
+} PeasObjectModulePrivate;
-#define GET_PRIV(o) \
- (peas_object_module_get_instance_private (o))
+G_DEFINE_TYPE_WITH_PRIVATE (PeasObjectModule, peas_object_module, G_TYPE_TYPE_MODULE)
#define TYPE_MISSING_PLUGIN_INFO_PROPERTY (G_TYPE_FLAG_RESERVED_ID_BIT)
@@ -96,7 +91,7 @@ static gboolean
peas_object_module_load (GTypeModule *gmodule)
{
PeasObjectModule *module = PEAS_OBJECT_MODULE (gmodule);
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
g_return_val_if_fail (priv->module_name != NULL, FALSE);
@@ -201,7 +196,7 @@ static void
peas_object_module_unload (GTypeModule *gmodule)
{
PeasObjectModule *module = PEAS_OBJECT_MODULE (gmodule);
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
ExtensionImplementation *impls;
guint i;
@@ -224,7 +219,7 @@ peas_object_module_unload (GTypeModule *gmodule)
static void
peas_object_module_init (PeasObjectModule *module)
{
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
priv->implementations = g_array_new (FALSE, FALSE,
sizeof (ExtensionImplementation));
@@ -234,7 +229,7 @@ static void
peas_object_module_finalize (GObject *object)
{
PeasObjectModule *module = PEAS_OBJECT_MODULE (object);
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
g_free (priv->path);
g_free (priv->module_name);
@@ -251,7 +246,7 @@ peas_object_module_get_property (GObject *object,
GParamSpec *pspec)
{
PeasObjectModule *module = PEAS_OBJECT_MODULE (object);
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
switch (prop_id)
{
@@ -283,7 +278,7 @@ peas_object_module_set_property (GObject *object,
GParamSpec *pspec)
{
PeasObjectModule *module = PEAS_OBJECT_MODULE (object);
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
switch (prop_id)
{
@@ -485,7 +480,7 @@ peas_object_module_create_object (PeasObjectModule *module,
guint n_parameters,
GParameter *parameters)
{
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
guint i;
ExtensionImplementation *impls;
@@ -520,7 +515,7 @@ gboolean
peas_object_module_provides_object (PeasObjectModule *module,
GType exten_type)
{
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
guint i;
ExtensionImplementation *impls;
@@ -549,7 +544,7 @@ peas_object_module_provides_object (PeasObjectModule *module,
const gchar *
peas_object_module_get_path (PeasObjectModule *module)
{
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
g_return_val_if_fail (PEAS_IS_OBJECT_MODULE (module), NULL);
@@ -567,7 +562,7 @@ peas_object_module_get_path (PeasObjectModule *module)
const gchar *
peas_object_module_get_module_name (PeasObjectModule *module)
{
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
g_return_val_if_fail (PEAS_IS_OBJECT_MODULE (module), NULL);
@@ -587,7 +582,7 @@ peas_object_module_get_module_name (PeasObjectModule *module)
const gchar *
peas_object_module_get_symbol (PeasObjectModule *module)
{
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
g_return_val_if_fail (PEAS_IS_OBJECT_MODULE (module), NULL);
@@ -605,7 +600,7 @@ peas_object_module_get_symbol (PeasObjectModule *module)
GModule *
peas_object_module_get_library (PeasObjectModule *module)
{
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
g_return_val_if_fail (PEAS_IS_OBJECT_MODULE (module), NULL);
@@ -640,7 +635,7 @@ peas_object_module_register_extension_factory (PeasObjectModule *module,
gpointer user_data,
GDestroyNotify destroy_func)
{
- PeasObjectModulePrivate *priv = GET_PRIV (module);
+ PeasObjectModulePrivate *priv = peas_object_module_get_instance_private (module);
ExtensionImplementation impl = { exten_type, factory_func, user_data, destroy_func };
g_return_if_fail (PEAS_IS_OBJECT_MODULE (module));
diff --git a/libpeas/peas-object-module.h b/libpeas/peas-object-module.h
index ce8ef53..be242d9 100644
--- a/libpeas/peas-object-module.h
+++ b/libpeas/peas-object-module.h
@@ -37,16 +37,10 @@
G_BEGIN_DECLS
-#define PEAS_TYPE_OBJECT_MODULE (peas_object_module_get_type ())
-#define PEAS_OBJECT_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PEAS_TYPE_OBJECT_MODULE, PeasObjectModule))
-#define PEAS_OBJECT_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PEAS_TYPE_OBJECT_MODULE, PeasObjectModuleClass))
-#define PEAS_IS_OBJECT_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PEAS_TYPE_OBJECT_MODULE))
-#define PEAS_IS_OBJECT_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PEAS_TYPE_OBJECT_MODULE))
-#define PEAS_OBJECT_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PEAS_TYPE_OBJECT_MODULE, PeasObjectModuleClass))
+#define PEAS_TYPE_OBJECT_MODULE (peas_object_module_get_type ())
-typedef struct _PeasObjectModule PeasObjectModule;
-typedef struct _PeasObjectModuleClass PeasObjectModuleClass;
-typedef struct _PeasObjectModulePrivate PeasObjectModulePrivate;
+PEAS_AVAILABLE_IN_ALL
+G_DECLARE_DERIVABLE_TYPE (PeasObjectModule, peas_object_module, PEAS, OBJECT_MODULE, GTypeModule)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
@@ -68,33 +62,20 @@ typedef GObject *(*PeasFactoryFunc) (guint n_parameters,
G_GNUC_END_IGNORE_DEPRECATIONS
/**
- * PeasObjectModule:
- *
- * The #PeasObjectModule structure contains only private data and should only
- * be accessed using the provided API.
- */
-struct _PeasObjectModule {
- GTypeModule parent;
-
- PeasObjectModulePrivate *priv;
-};
-
-/**
* PeasObjectModuleClass:
* @parent_class: The parent class.
*
* The class structure for #PeasObjectModule.
*/
-struct _PeasObjectModuleClass {
+struct _PeasObjectModuleClass
+{
GTypeModuleClass parent_class;
/*< private >*/
- gpointer padding[8];
+ gpointer _reserved[8];
};
PEAS_AVAILABLE_IN_ALL
-GType peas_object_module_get_type (void) G_GNUC_CONST;
-PEAS_AVAILABLE_IN_ALL
PeasObjectModule *peas_object_module_new (const gchar *module_name,
const gchar *path,
gboolean resident);