diff options
author | Garrett Regier <garrettregier@gmail.com> | 2015-09-21 21:46:38 -0700 |
---|---|---|
committer | Garrett Regier <garrettregier@gmail.com> | 2015-09-22 01:04:38 -0700 |
commit | 5085a1b17fed682feaa2511d30d908fa860f5287 (patch) | |
tree | cdfef62189b4947205948bb7af4753f7b8dcbf18 | |
parent | 12bedd69a6e6db7f139ea0e97d16a6efbcc53faf (diff) | |
download | libpeas-5085a1b17fed682feaa2511d30d908fa860f5287.tar.gz |
Add PEAS_UTILS_C_LOADER_ID
This simplifies various C plugin loader specific code.
-rw-r--r-- | libpeas/peas-engine.c | 12 | ||||
-rw-r--r-- | libpeas/peas-plugin-info.c | 2 | ||||
-rw-r--r-- | libpeas/peas-utils.h | 3 |
3 files changed, 12 insertions, 5 deletions
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c index 0f3349d..27ebd7d 100644 --- a/libpeas/peas-engine.c +++ b/libpeas/peas-engine.c @@ -352,7 +352,7 @@ peas_engine_init (PeasEngine *engine) priv->in_dispose = FALSE; /* The C plugin loader is always enabled */ - priv->loaders[peas_utils_get_loader_id ("C")].enabled = TRUE; + priv->loaders[PEAS_UTILS_C_LOADER_ID].enabled = TRUE; } /** @@ -628,8 +628,14 @@ peas_engine_class_init (PeasEngineClass *klass) * global init function for libpeas. */ peas_debug_init (); + /* This cannot be done as a compile-time + * assert, but is critical for correct behavior + */ + g_assert (g_strcmp0 (peas_utils_get_loader_from_id (PEAS_UTILS_C_LOADER_ID), + "c") == 0); + /* The C plugin loader is always enabled */ - loaders[peas_utils_get_loader_id ("C")].enabled = TRUE; + loaders[PEAS_UTILS_C_LOADER_ID].enabled = TRUE; } static PeasObjectModule * @@ -669,7 +675,7 @@ create_plugin_loader (gint loader_id) { PeasPluginLoader *loader; - if (peas_utils_get_loader_id ("C") == loader_id) + if (loader_id == PEAS_UTILS_C_LOADER_ID) { loader = peas_plugin_loader_c_new (); } diff --git a/libpeas/peas-plugin-info.c b/libpeas/peas-plugin-info.c index c8292a2..b30e82b 100644 --- a/libpeas/peas-plugin-info.c +++ b/libpeas/peas-plugin-info.c @@ -169,7 +169,7 @@ _peas_plugin_info_new (const gchar *filename, if (loader == NULL || *loader == '\0') { /* Default to the C loader */ - info->loader_id = peas_utils_get_loader_id ("C"); + info->loader_id = PEAS_UTILS_C_LOADER_ID; } else { diff --git a/libpeas/peas-utils.h b/libpeas/peas-utils.h index df8e45b..adca711 100644 --- a/libpeas/peas-utils.h +++ b/libpeas/peas-utils.h @@ -24,7 +24,8 @@ #include <glib-object.h> -#define PEAS_UTILS_N_LOADERS 4 +#define PEAS_UTILS_C_LOADER_ID 0 +#define PEAS_UTILS_N_LOADERS 4 gboolean peas_utils_valist_to_parameter_list (GType iface_type, const gchar *first_property, |