gplugin/gplugin

Parents c7bb38cfbd00
Children fb61d7111522
Change loader registration to work on an instance rather than a GType

Testing Done:
Ran the unit tests in valgrind and verifed there was no new memory leaks in the loader registration. Right now the plugins themselfs leak a reference, but I'll be cleaning that up shortly.

Reviewed at https://reviews.imfreedom.org/r/899/
--- a/gplugin/gplugin-manager.c Thu Sep 23 23:19:13 2021 -0500
+++ b/gplugin/gplugin-manager.c Thu Sep 23 23:30:36 2021 -0500
@@ -80,7 +80,7 @@
GHashTable *plugins;
GHashTable *plugins_filename_view;
- GSList *loaders;
+ GHashTable *loaders;
GHashTable *loaders_by_extension;
gboolean refresh_needed;
@@ -92,6 +92,7 @@
* Globals
*****************************************************************************/
GPluginManager *default_manager = NULL;
+GPluginLoader *native_loader = NULL;
static guint signals[N_SIGNALS] = {
0,
};
@@ -129,34 +130,6 @@
return TRUE;
}
-/*
- * gplugin_manager_find_loader_by_type:
- * @manager: The #GPluginManager instance.
- * @type: The #GType of the loader to find.
- *
- * Looks up a #GPluginLoader instance by its type.
- *
- * Returns: (transfer none): The #GPluginLoader instance or %NULL.
- */
-static GPluginLoader *
-gplugin_manager_find_loader_by_type(GPluginManager *manager, GType type)
-{
- GPluginManagerPrivate *priv = NULL;
- GSList *l = NULL;
-
- g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), NULL);
- g_return_val_if_fail(g_type_is_a(type, GPLUGIN_TYPE_LOADER), NULL);
-
- priv = gplugin_manager_get_instance_private(manager);
- for(l = priv->loaders; l; l = l->next) {
- if(G_OBJECT_TYPE(l->data) == type) {
- return GPLUGIN_LOADER(l->data);
- }
- }
-
- return NULL;
-}
-
static void
gplugin_manager_foreach_unload_plugin(
gpointer key,
@@ -304,8 +277,7 @@
g_clear_pointer(&priv->plugins_filename_view, g_hash_table_destroy);
/* clean up our list of loaders */
- g_slist_free_full(priv->loaders, g_object_unref);
- priv->loaders = NULL;
+ g_clear_pointer(&priv->loaders, g_hash_table_destroy);
/* free all the data in the loaders hash table and destroy it */
g_hash_table_foreach_remove(
@@ -475,6 +447,9 @@
priv->plugins_filename_view =
g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
+ priv->loaders =
+ g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
+
/* The loaders_by_extension hash table is keyed on the supported extensions
* of the loader. Which means that a loader that supports multiple
* extensions will be in the table multiple times.
@@ -508,9 +483,11 @@
default_manager = g_object_new(GPLUGIN_TYPE_MANAGER, NULL);
if(register_native_loader) {
+ native_loader = gplugin_native_loader_new();
+
if(!gplugin_manager_register_loader(
default_manager,
- GPLUGIN_TYPE_NATIVE_LOADER,
+ native_loader,
&error)) {
if(error != NULL) {
g_error("failed to register loader: %s", error->message);
@@ -527,6 +504,8 @@
void
gplugin_manager_private_uninit(void)
{
+ g_clear_object(&native_loader);
+
g_regex_unref(dependency_regex);
g_clear_object(&default_manager);
@@ -731,7 +710,7 @@
/**
* gplugin_manager_register_loader:
* @manager: The #GPluginManager instance.
- * @type: #GType of a #GPluginLoader.
+ * @loader: The #GPluginLoader instance to register.
* @error: (out) (nullable): The return address for a #GError.
*
* Registers @type as an available loader.
@@ -742,44 +721,32 @@
gboolean
gplugin_manager_register_loader(
GPluginManager *manager,
- GType type,
+ GPluginLoader *loader,
GError **error)
{
GPluginManagerPrivate *priv = NULL;
- GPluginLoader *loader = NULL;
+ GPluginLoader *found = NULL;
GSList *l = NULL, *exts = NULL;
+ const gchar *id = NULL;
g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), FALSE);
- g_return_val_if_fail(g_type_is_a(type, GPLUGIN_TYPE_LOADER), FALSE);
+ g_return_val_if_fail(GPLUGIN_IS_LOADER(loader), FALSE);
+
+ priv = gplugin_manager_get_instance_private(manager);
- loader = gplugin_manager_find_loader_by_type(manager, type);
- if(GPLUGIN_IS_LOADER(loader)) {
+ id = gplugin_loader_get_id(loader);
+ found = g_hash_table_lookup(priv->loaders, id);
+ if(GPLUGIN_IS_LOADER(found)) {
g_set_error(
error,
GPLUGIN_DOMAIN,
0,
_("loader %s was already registered"),
- g_type_name(type));
+ id);
return FALSE;
}
- /* Create the loader instance first. If we can't create it, we bail */
- loader = g_object_new(type, NULL);
- if(!GPLUGIN_IS_LOADER(loader)) {
- g_set_error(
- error,
- GPLUGIN_DOMAIN,
- 0,
- _("failed to create loader instance for %s"),
- g_type_name(type));
-
- return FALSE;
- }
-
- priv = gplugin_manager_get_instance_private(manager);
-
- priv->loaders =
- g_slist_prepend(priv->loaders, g_object_ref(G_OBJECT(loader)));
+ g_hash_table_insert(priv->loaders, g_strdup(id), g_object_ref(loader));
exts = gplugin_loader_get_supported_extensions(loader);
for(l = exts; l; l = l->next) {
@@ -792,18 +759,19 @@
*/
existing = g_hash_table_lookup(priv->loaders_by_extension, ext);
for(ll = existing; ll; ll = ll->next) {
- if(G_OBJECT_TYPE(ll->data) == type) {
- GPluginLoader *old = GPLUGIN_LOADER(ll->data);
+ GPluginLoader *iter = GPLUGIN_LOADER(ll->data);
+ const gchar *ext_id = gplugin_loader_get_id(iter);
- existing = g_slist_remove(existing, old);
+ if(g_str_equal(id, ext_id)) {
+ existing = g_slist_remove(existing, iter);
- g_object_unref(G_OBJECT(old));
+ g_object_unref(iter);
break;
}
}
- existing = g_slist_prepend(existing, g_object_ref(G_OBJECT(loader)));
+ existing = g_slist_prepend(existing, g_object_ref(loader));
/* Now insert the updated slist back into the hash table */
g_hash_table_insert(
@@ -816,16 +784,13 @@
/* make a note that we need to refresh */
priv->refresh_needed = TRUE;
- /* we remove our initial reference from the loader now to avoid a leak */
- g_object_unref(G_OBJECT(loader));
-
return TRUE;
}
/**
* gplugin_manager_unregister_loader:
* @manager: The #GPluginManager instance.
- * @type: #GType of a #GPluginLoader.
+ * @loader: The #GPluginLoader instance to unregister.
* @error: (out) (nullable): The return address for a #GError.
*
* Unregisters @type as an available loader.
@@ -836,30 +801,32 @@
gboolean
gplugin_manager_unregister_loader(
GPluginManager *manager,
- GType type,
+ GPluginLoader *loader,
GError **error)
{
GPluginManagerPrivate *priv = NULL;
- GPluginLoader *loader = NULL;
GSList *l = NULL, *exts = NULL;
+ const gchar *id = NULL;
g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), FALSE);
- g_return_val_if_fail(g_type_is_a(type, GPLUGIN_TYPE_LOADER), FALSE);
+ g_return_val_if_fail(GPLUGIN_IS_LOADER(loader), FALSE);
+
+ priv = gplugin_manager_get_instance_private(manager);
- loader = gplugin_manager_find_loader_by_type(manager, type);
+ id = gplugin_loader_get_id(loader);
+
+ loader = g_hash_table_lookup(priv->loaders, id);
if(!GPLUGIN_IS_LOADER(loader)) {
g_set_error(
error,
GPLUGIN_DOMAIN,
0,
_("loader %s is not registered"),
- g_type_name(type));
+ id);
return FALSE;
}
- priv = gplugin_manager_get_instance_private(manager);
-
exts = gplugin_loader_get_supported_extensions(loader);
for(l = exts; l; l = l->next) {
GSList *los = NULL;
@@ -871,15 +838,16 @@
for(ll = los; ll; ll = ll->next) {
GPluginLoader *lo = GPLUGIN_LOADER(ll->data);
+ const gchar *lo_id = gplugin_loader_get_id(lo);
/* check if this is not the loader we're looking for */
- if(G_OBJECT_TYPE(lo) != type)
+ if(!g_str_equal(id, lo_id)) {
continue;
+ }
- /* at this point, the loader we're at is of the type we're
- * removing. So we'll remove it from the los SList. Then if the
- * SList is empty, we remove it from the hash table, otherwise we
- * just update it.
+ /* At this point, we're at the loader that we're removing. So we'll
+ * remove it from the los SList. Then if the SList is empty, we
+ * remove it from the hash table, otherwise we just update it.
*/
los = g_slist_remove(los, lo);
if(los) {
@@ -892,7 +860,7 @@
}
/* kill our ref to the loader */
- g_object_unref(G_OBJECT(lo));
+ g_object_unref(lo);
/* now move to the next extension to check */
break;
@@ -900,8 +868,7 @@
}
g_slist_free(exts);
- priv->loaders = g_slist_remove(priv->loaders, loader);
- g_object_unref(G_OBJECT(loader));
+ g_hash_table_remove(priv->loaders, id);
return TRUE;
}
@@ -912,10 +879,10 @@
*
* Returns a list of all registered #GPluginLoader's.
*
- * Returns: (element-type GPlugin.Loader) (transfer full): Returns a list of all
- * registered loaders.
+ * Returns: (element-type GPlugin.Loader) (transfer container): Returns a list
+ * of all registered loaders.
*/
-GSList *
+GList *
gplugin_manager_get_loaders(GPluginManager *manager)
{
GPluginManagerPrivate *priv = NULL;
@@ -924,7 +891,7 @@
priv = gplugin_manager_get_instance_private(manager);
- return g_slist_copy_deep(priv->loaders, (GCopyFunc)g_object_ref, NULL);
+ return g_hash_table_get_values(priv->loaders);
}
/**
--- a/gplugin/gplugin-manager.h Thu Sep 23 23:19:13 2021 -0500
+++ b/gplugin/gplugin-manager.h Thu Sep 23 23:30:36 2021 -0500
@@ -81,13 +81,13 @@
gboolean gplugin_manager_register_loader(
GPluginManager *manager,
- GType type,
+ GPluginLoader *loader,
GError **error);
gboolean gplugin_manager_unregister_loader(
GPluginManager *manager,
- GType type,
+ GPluginLoader *loader,
GError **error);
-GSList *gplugin_manager_get_loaders(GPluginManager *manager);
+GList *gplugin_manager_get_loaders(GPluginManager *manager);
void gplugin_manager_refresh(GPluginManager *manager);
--- a/gplugin/gplugin-native-loader.c Thu Sep 23 23:19:13 2021 -0500
+++ b/gplugin/gplugin-native-loader.c Thu Sep 23 23:30:36 2021 -0500
@@ -352,3 +352,32 @@
loader_class->load = gplugin_native_loader_load;
loader_class->unload = gplugin_native_loader_unload;
}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+
+/**
+ * gplugin_native_loader_new:
+ *
+ * Create a new instance of the native plugin loader.
+ *
+ * Typically you won't need to call this directly as GPlugin will create it
+ * unless #GPLUGIN_CORE_FLAGS_DISABLE_NATIVE_LOADER is passed to
+ * gplugin_init().
+ *
+ * Returns: (transfer full): The new instance.
+ *
+ * Since: 0.34.0
+ */
+GPluginLoader *
+gplugin_native_loader_new(void)
+{
+ /* clang-format off */
+ return g_object_new(
+ GPLUGIN_TYPE_NATIVE_LOADER,
+ "id", "gplugin-native",
+ NULL);
+ /* clang-format on */
+}
+
--- a/gplugin/gplugin-native-loader.h Thu Sep 23 23:19:13 2021 -0500
+++ b/gplugin/gplugin-native-loader.h Thu Sep 23 23:30:36 2021 -0500
@@ -39,6 +39,8 @@
NATIVE_LOADER,
GPluginLoader)
+GPluginLoader *gplugin_native_loader_new(void);
+
G_END_DECLS
#endif /* GPLUGIN_NATIVE_LOADER_H */
--- a/gplugin/tests/test-loader-registration.c Thu Sep 23 23:19:13 2021 -0500
+++ b/gplugin/tests/test-loader-registration.c Thu Sep 23 23:30:36 2021 -0500
@@ -88,6 +88,16 @@
loader_class->unload = test_gplugin_loader_unload;
}
+static GPluginLoader *
+test_gplugin_loader_new(void)
+{
+ /* clang-format off */
+ return GPLUGIN_LOADER(g_object_new(
+ TEST_GPLUGIN_TYPE_LOADER,
+ "id", "test-loader",
+ NULL));
+ /* clang-format on */
+}
/******************************************************************************
* Tests
*****************************************************************************/
@@ -95,33 +105,7 @@
test_gplugin_manager_loader_register_unregister(void)
{
GPluginManager *manager = NULL;
- GError *error = NULL;
- gboolean ret;
-
- gplugin_manager_private_uninit();
- gplugin_manager_private_init(TRUE);
-
- manager = gplugin_manager_get_default();
-
- ret = gplugin_manager_register_loader(
- manager,
- TEST_GPLUGIN_TYPE_LOADER,
- &error);
- g_assert_no_error(error);
- g_assert_true(ret);
-
- ret = gplugin_manager_unregister_loader(
- manager,
- TEST_GPLUGIN_TYPE_LOADER,
- &error);
- g_assert_no_error(error);
- g_assert_true(ret);
-}
-
-static void
-test_gplugin_manager_loader_register_twice(void)
-{
- GPluginManager *manager = NULL;
+ GPluginLoader *loader = NULL;
GError *error = NULL;
gboolean ret;
@@ -130,33 +114,24 @@
manager = gplugin_manager_get_default();
- ret = gplugin_manager_register_loader(
- manager,
- TEST_GPLUGIN_TYPE_LOADER,
- &error);
+ loader = test_gplugin_loader_new();
+
+ ret = gplugin_manager_register_loader(manager, loader, &error);
g_assert_no_error(error);
g_assert_true(ret);
- ret = gplugin_manager_register_loader(
- manager,
- TEST_GPLUGIN_TYPE_LOADER,
- &error);
- g_assert_false(ret);
- g_assert_error(error, GPLUGIN_DOMAIN, 0);
- g_clear_error(&error);
-
- ret = gplugin_manager_unregister_loader(
- manager,
- TEST_GPLUGIN_TYPE_LOADER,
- &error);
+ ret = gplugin_manager_unregister_loader(manager, loader, &error);
g_assert_no_error(error);
g_assert_true(ret);
+
+ g_clear_object(&loader);
}
static void
-test_gplugin_manager_loader_unregister_twice(void)
+test_gplugin_manager_loader_register_twice(void)
{
GPluginManager *manager = NULL;
+ GPluginLoader *loader = NULL;
GError *error = NULL;
gboolean ret;
@@ -165,27 +140,53 @@
manager = gplugin_manager_get_default();
- ret = gplugin_manager_register_loader(
- manager,
- TEST_GPLUGIN_TYPE_LOADER,
- &error);
+ loader = test_gplugin_loader_new();
+
+ ret = gplugin_manager_register_loader(manager, loader, &error);
+ g_assert_no_error(error);
+ g_assert_true(ret);
+
+ ret = gplugin_manager_register_loader(manager, loader, &error);
+ g_assert_false(ret);
+ g_assert_error(error, GPLUGIN_DOMAIN, 0);
+ g_clear_error(&error);
+
+ ret = gplugin_manager_unregister_loader(manager, loader, &error);
g_assert_no_error(error);
g_assert_true(ret);
- ret = gplugin_manager_unregister_loader(
- manager,
- TEST_GPLUGIN_TYPE_LOADER,
- &error);
+ g_clear_object(&loader);
+}
+
+static void
+test_gplugin_manager_loader_unregister_twice(void)
+{
+ GPluginManager *manager = NULL;
+ GPluginLoader *loader = NULL;
+ GError *error = NULL;
+ gboolean ret;
+
+ gplugin_manager_private_uninit();
+ gplugin_manager_private_init(TRUE);
+
+ manager = gplugin_manager_get_default();
+
+ loader = test_gplugin_loader_new();
+
+ ret = gplugin_manager_register_loader(manager, loader, &error);
g_assert_no_error(error);
g_assert_true(ret);
- ret = gplugin_manager_unregister_loader(
- manager,
- TEST_GPLUGIN_TYPE_LOADER,
- &error);
+ ret = gplugin_manager_unregister_loader(manager, loader, &error);
+ g_assert_no_error(error);
+ g_assert_true(ret);
+
+ ret = gplugin_manager_unregister_loader(manager, loader, &error);
g_assert_false(ret);
g_assert_error(error, GPLUGIN_DOMAIN, 0);
g_clear_error(&error);
+
+ g_clear_object(&loader);
}
/******************************************************************************
--- a/lua/gplugin-lua-core.c Thu Sep 23 23:19:13 2021 -0500
+++ b/lua/gplugin-lua-core.c Thu Sep 23 23:30:36 2021 -0500
@@ -23,6 +23,8 @@
#include "gplugin-lua-loader.h"
#include "gplugin-lua-plugin.h"
+static GPluginLoader *loader = NULL;
+
static GPluginPluginInfo *
gplugin_lua_query(G_GNUC_UNUSED GError **error)
{
@@ -63,10 +65,14 @@
gplugin_lua_loader_register(G_TYPE_MODULE(plugin));
gplugin_lua_plugin_register(G_TYPE_MODULE(plugin));
- return gplugin_manager_register_loader(
- manager,
- GPLUGIN_LUA_TYPE_LOADER,
- error);
+ loader = gplugin_lua_loader_new();
+ if(!gplugin_manager_register_loader(manager, loader, error)) {
+ g_clear_object(&loader);
+
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
--- a/lua/gplugin-lua-loader.c Thu Sep 23 23:19:13 2021 -0500
+++ b/lua/gplugin-lua-loader.c Thu Sep 23 23:30:36 2021 -0500
@@ -215,3 +215,14 @@
{
gplugin_lua_loader_register_type(module);
}
+
+GPluginLoader *
+gplugin_lua_loader_new(void)
+{
+ /* clang-format off */
+ return GPLUGIN_LOADER(g_object_new(
+ GPLUGIN_LUA_TYPE_LOADER,
+ "id", "gplugin-lua5",
+ NULL));
+ /* clang-format on */
+}
--- a/lua/gplugin-lua-loader.h Thu Sep 23 23:19:13 2021 -0500
+++ b/lua/gplugin-lua-loader.h Thu Sep 23 23:30:36 2021 -0500
@@ -33,6 +33,8 @@
void gplugin_lua_loader_register(GTypeModule *module);
+GPluginLoader *gplugin_lua_loader_new(void);
+
G_END_DECLS
#endif /* GPLUGIN_LUA_LOADER_H */
--- a/perl5/gplugin-perl5-core.c Thu Sep 23 23:19:13 2021 -0500
+++ b/perl5/gplugin-perl5-core.c Thu Sep 23 23:30:36 2021 -0500
@@ -24,6 +24,8 @@
#undef _
#include <glib/gi18n-lib.h>
+static GPluginLoader *loader = NULL;
+
static GPluginPluginInfo *
gplugin_perl5_query(G_GNUC_UNUSED GError **error)
{
@@ -62,10 +64,14 @@
gplugin_perl_plugin_register(G_TYPE_MODULE(plugin));
gplugin_perl_loader_register(G_TYPE_MODULE(plugin));
- return gplugin_manager_register_loader(
- manager,
- GPLUGIN_PERL_TYPE_LOADER,
- error);
+ loader = gplugin_perl_loader_new();
+ if(!gplugin_manager_register_loader(manager, loader, error)) {
+ g_clear_object(&loader);
+
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
--- a/perl5/gplugin-perl5-loader.c Thu Sep 23 23:19:13 2021 -0500
+++ b/perl5/gplugin-perl5-loader.c Thu Sep 23 23:30:36 2021 -0500
@@ -374,3 +374,14 @@
{
gplugin_perl_loader_register_type(module);
}
+
+GPluginLoader *
+gplugin_perl_loader_new(void)
+{
+ /* clang-format off */
+ return GPLUGIN_LOADER(g_object_new(
+ GPLUGIN_PERL_TYPE_LOADER,
+ "id", "gplugin-perl5",
+ NULL));
+ /* clang-format on */
+}
--- a/perl5/gplugin-perl5-loader.h Thu Sep 23 23:19:13 2021 -0500
+++ b/perl5/gplugin-perl5-loader.h Thu Sep 23 23:30:36 2021 -0500
@@ -33,6 +33,8 @@
void gplugin_perl_loader_register(GTypeModule *module);
+GPluginLoader *gplugin_perl_loader_new(void);
+
G_END_DECLS
#endif /* GPLUGIN_PERL_PLUGIN_LOADER_H */
--- a/python3/gplugin-python3-core.c Thu Sep 23 23:19:13 2021 -0500
+++ b/python3/gplugin-python3-core.c Thu Sep 23 23:30:36 2021 -0500
@@ -23,6 +23,8 @@
#include "gplugin-python3-loader.h"
#include "gplugin-python3-plugin.h"
+static GPluginLoader *loader = NULL;
+
static GPluginPluginInfo *
gplugin_python3_query(G_GNUC_UNUSED GError **error)
{
@@ -63,10 +65,15 @@
gplugin_python3_plugin_register(G_TYPE_MODULE(plugin));
gplugin_python3_loader_register(G_TYPE_MODULE(plugin));
- return gplugin_manager_register_loader(
- manager,
- GPLUGIN_PYTHON3_TYPE_LOADER,
- error);
+ loader = gplugin_python3_loader_new();
+
+ if(!gplugin_manager_register_loader(manager, loader, error)) {
+ g_clear_object(&loader);
+
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
--- a/python3/gplugin-python3-loader.c Thu Sep 23 23:19:13 2021 -0500
+++ b/python3/gplugin-python3-loader.c Thu Sep 23 23:30:36 2021 -0500
@@ -405,3 +405,14 @@
gplugin_python3_loader_init_python();
}
+
+GPluginLoader *
+gplugin_python3_loader_new(void)
+{
+ /* clang-format off */
+ return GPLUGIN_LOADER(g_object_new(
+ GPLUGIN_PYTHON3_TYPE_LOADER,
+ "id", "gplugin-python3",
+ NULL));
+ /* clang-format on */
+}
--- a/python3/gplugin-python3-loader.h Thu Sep 23 23:19:13 2021 -0500
+++ b/python3/gplugin-python3-loader.h Thu Sep 23 23:30:36 2021 -0500
@@ -33,6 +33,8 @@
void gplugin_python3_loader_register(GTypeModule *module);
+GPluginLoader *gplugin_python3_loader_new(void);
+
G_END_DECLS
#endif /* GPLUGIN_PYTHON3_LOADER_H */
--- a/tcc/gplugin-tcc-core.c Thu Sep 23 23:19:13 2021 -0500
+++ b/tcc/gplugin-tcc-core.c Thu Sep 23 23:30:36 2021 -0500
@@ -23,6 +23,8 @@
#include "gplugin-tcc-loader.h"
#include "gplugin-tcc-plugin.h"
+static GPluginLoader *loader = NULL;
+
G_MODULE_EXPORT GPluginPluginInfo *
gplugin_query(G_GNUC_UNUSED GError **error)
{
@@ -50,10 +52,21 @@
G_MODULE_EXPORT gboolean
gplugin_load(GPluginNativePlugin *plugin, GError **error)
{
+ GPluginManager *manager = NULL;
+
gplugin_tcc_loader_register(plugin);
gplugin_tcc_plugin_register(plugin);
- return gplugin_manager_register_loader(GPLUGIN_TCC_TYPE_LOADER, error);
+ manager = gplugin_manager_get_default();
+
+ loader = gplugin_tcc_loader_new();
+ if(!gplugin_manager_register_loader(manager, loader, error)) {
+ g_clear_object(&loader);
+
+ return FALSE;
+ }
+
+ return TRUE;
}
G_MODULE_EXPORT gboolean
--- a/tcc/gplugin-tcc-loader.c Thu Sep 23 23:19:13 2021 -0500
+++ b/tcc/gplugin-tcc-loader.c Thu Sep 23 23:30:36 2021 -0500
@@ -38,7 +38,7 @@
static GSList *
gplugin_tcc_loader_supported_extensions(G_GNUC_UNUSED GPluginLoader *l)
{
- return g_list_append(NULL, "c");
+ return g_slist_append(NULL, "c");
}
static GPluginPlugin *
@@ -208,3 +208,14 @@
{
gplugin_tcc_loader_register_type(G_TYPE_MODULE(plugin));
}
+
+GPluginLoader *
+gplugin_tcc_loader_new(void)
+{
+ /* clang-format off */
+ return GPLUGIN_LOADER(g_object_new(
+ GPLUGIN_TCC_TYPE_LOADER,
+ "id", "gplugin-tcc",
+ NULL));
+ /* clang-format on */
+}
--- a/tcc/gplugin-tcc-loader.h Thu Sep 23 23:19:13 2021 -0500
+++ b/tcc/gplugin-tcc-loader.h Thu Sep 23 23:30:36 2021 -0500
@@ -32,6 +32,8 @@
void gplugin_tcc_loader_register(GPluginNativePlugin *plugin);
+GPluginLoader *gplugin_tcc_loader_new(void);
+
G_END_DECLS
#endif /* GPLUGIN_TCC_LOADER_H */