--- a/gplugin/gplugin-manager.c Mon Oct 08 00:55:11 2018 -0500
+++ b/gplugin/gplugin-manager.c Mon Oct 08 20:27:16 2018 -0500
@@ -86,6 +86,8 @@
GList *(*list_plugins)(GPluginManager *manager);
+ GSList *(*get_plugin_dependencies)(GPluginManager *manager, GPluginPlugin *plugin, GError **error); gboolean (*load_plugin)(GPluginManager *manager,
@@ -455,8 +457,7 @@
/* we want the internal filename from the plugin to avoid
* duplicate memory, so we need to grab it for the "view".
- gplugin_plugin_get_internal_filename(plugin);
+ gchar *real_filename = gplugin_plugin_get_filename(plugin); /* we also need the GPluginPluginInfo to get the plugin's
* ID for the key in our main hash table.
@@ -687,7 +688,8 @@
ret = gplugin_manager_load_plugin(dplugin, error);
- gplugin_plugin_add_dependent_plugin(dplugin, plugin);
+# warning need to figure out dependencies +// gplugin_plugin_add_dependent_plugin(dplugin, plugin); g_object_unref(G_OBJECT(dplugin));
@@ -714,6 +716,47 @@
+gplugin_manager_real_get_plugin_dependencies(GPluginManager *manager, + GPluginPluginInfo *info = NULL; + const gchar * const *dependencies = NULL; + info = gplugin_plugin_get_info(plugin); + dependencies = gplugin_plugin_info_get_dependencies(info); + if(dependencies == NULL) { + for(idx = 0; dependencies[idx] != NULL; idx++) { + GPluginPlugin *dep = gplugin_manager_find_plugin(dependencies[idx]); + if(!GPLUGIN_IS_PLUGIN(dep)) { + "failed to find plugin dependency '%s'", + g_slist_free_full(ret, g_object_unref); + ret = g_slist_prepend(ret, dep); gplugin_manager_real_load_plugin(GPluginManager *manager,
@@ -891,6 +934,8 @@
manager_class->find_plugins = gplugin_manager_real_find_plugins;
manager_class->list_plugins = gplugin_manager_real_list_plugins;
+ manager_class->get_plugin_dependencies = gplugin_manager_real_get_plugin_dependencies; manager_class->load_plugin = gplugin_manager_real_load_plugin;
manager_class->unload_plugin = gplugin_manager_real_unload_plugin;
@@ -919,7 +964,7 @@
gplugin_marshal_BOOLEAN__OBJECT_POINTER,
- GPLUGIN_TYPE_PLUGIN, G_TYPE_POINTER);
+ G_TYPE_OBJECT, G_TYPE_POINTER); * GPluginManager::loaded-plugin:
@@ -939,7 +984,7 @@
gplugin_marshal_VOID__OBJECT,
* GPluginManager::load-failed:
@@ -958,7 +1003,7 @@
gplugin_marshal_VOID__OBJECT,
* GPluginManager::unloading-plugin:
@@ -979,7 +1024,7 @@
gplugin_marshal_BOOLEAN__OBJECT_POINTER,
- GPLUGIN_TYPE_PLUGIN, G_TYPE_POINTER);
+ G_TYPE_OBJECT, G_TYPE_POINTER); * GPluginManager::unloaded-plugin:
@@ -999,7 +1044,7 @@
gplugin_marshal_VOID__OBJECT,
@@ -1335,6 +1380,34 @@
+ * gplugin_manager_get_plugin_dependencies: + * @plugin: The #GPluginPlugin whose dependencies to get. + * @error: Return address for a #GError. + * Returns a list of all the #GPluginPlugin's that @plugin depends on. + * Return value: (element-type GPlugin.Plugin) (transfer full): A #GSList of + * #GPluginPlugin's that @plugin depends on, or NULL on error +gplugin_manager_get_plugin_dependencies(GPluginPlugin *plugin, GError **error) { + GPluginManager *manager = NULL; + GPluginManagerClass *klass = NULL; + g_return_val_if_fail(GPLUGIN_IS_PLUGIN(plugin), NULL); + manager = GPLUGIN_MANAGER_INSTANCE; + g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), NULL); + klass = GPLUGIN_MANAGER_GET_CLASS(manager); + if(klass && klass->get_plugin_dependencies) { + return klass->get_plugin_dependencies(manager, plugin, error); * gplugin_manager_load_plugin:
--- a/gplugin/gplugin-manager.h Mon Oct 08 00:55:11 2018 -0500
+++ b/gplugin/gplugin-manager.h Mon Oct 08 20:27:16 2018 -0500
@@ -51,6 +51,8 @@
GPluginPlugin *gplugin_manager_find_plugin(const gchar *id);
+GSList *gplugin_manager_get_plugin_dependencies(GPluginPlugin *plugin, GError **error); gboolean gplugin_manager_load_plugin(GPluginPlugin *plugin, GError **error);
gboolean gplugin_manager_unload_plugin(GPluginPlugin *plugin, GError **error);
--- a/gplugin/gplugin-native-loader.c Mon Oct 08 00:55:11 2018 -0500
+++ b/gplugin/gplugin-native-loader.c Mon Oct 08 20:27:16 2018 -0500
@@ -226,19 +226,8 @@
g_return_val_if_fail(plugin != NULL, FALSE);
g_return_val_if_fail(GPLUGIN_IS_NATIVE_PLUGIN(plugin), FALSE);
+ /* get and call the function */ g_object_get(G_OBJECT(plugin), "load-func", &func, NULL);
- /* validate the function */
- const char *filename = gplugin_plugin_get_filename(plugin);
- g_warning(_("load function for %s is NULL"), filename);
- /* now call the function */
if(!func(GPLUGIN_NATIVE_PLUGIN(plugin), error)) {
if(error && *error == NULL)
*error = g_error_new(GPLUGIN_DOMAIN, 0, _("unknown failure"));
--- a/gplugin/gplugin-native-plugin.c Mon Oct 08 00:55:11 2018 -0500
+++ b/gplugin/gplugin-native-plugin.c Mon Oct 08 20:27:16 2018 -0500
@@ -44,26 +44,12 @@
- GSList *interface_infos;
+ GPluginPluginInfo *info; + GPluginPluginState state; } GPluginNativePluginPrivate;
-} GPluginNativePluginTypeInfo;
-} GPluginNativePluginInterfaceInfo;
/******************************************************************************
*****************************************************************************/
@@ -73,148 +59,58 @@
+ PROP_FILENAME = N_PROPERTIES, static GParamSpec *properties[N_PROPERTIES] = {NULL,};
/* I hate forward declarations... */
-static void gplugin_native_plugin_iface_init(GTypePluginClass *iface);
+static void gplugin_native_plugin_iface_init(GPluginPluginInterface *iface);
G_ADD_PRIVATE(GPluginNativePlugin)
- G_IMPLEMENT_INTERFACE(G_TYPE_TYPE_PLUGIN, gplugin_native_plugin_iface_init)
+ G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_native_plugin_iface_init) /******************************************************************************
+ * GPluginPlugin Implementation *****************************************************************************/
-static GPluginNativePluginTypeInfo *
-gplugin_native_plugin_find_type_info(GPluginNativePlugin *plugin, GType type) {
- GPluginNativePluginPrivate *priv = gplugin_native_plugin_get_instance_private(plugin);
- for(l = priv->type_infos; l; l = l->next) {
- GPluginNativePluginTypeInfo *info =
- (GPluginNativePluginTypeInfo *)(l->data);
-static GPluginNativePluginInterfaceInfo *
-gplugin_native_plugin_find_interface_info(GPluginNativePlugin *plugin,
- GPluginNativePluginPrivate *priv = gplugin_native_plugin_get_instance_private(plugin);
- for(l = priv->interface_infos; l; l = l->next) {
- GPluginNativePluginInterfaceInfo *info =
- (GPluginNativePluginInterfaceInfo *)(l->data);
- if(info->instance_type == instance_type &&
- info->interface_type == interface_type)
+gplugin_native_plugin_iface_init(GPluginPluginInterface *iface) { /******************************************************************************
- * GTypePlugin Implementation
+ * GPluginPlugin Implementation *****************************************************************************/
-gplugin_native_plugin_priv_use(GTypePlugin *plugin) {
- GPluginNativePlugin *native = GPLUGIN_NATIVE_PLUGIN(plugin);
- if(!gplugin_native_plugin_use(native, &error)) {
- GPluginPluginInfo *info =
- gplugin_plugin_get_info(GPLUGIN_PLUGIN(native));
- const gchar *name = NULL;
+gplugin_native_plugin_load(GTypeModule *module) { + // GPluginNativePlugin *native = GPLUGIN_NATIVE_PLUGIN(module); + // GPluginNativePluginPrivate *priv = gplugin_native_plugin_get_instance_private(native); + // GError *error = NULL; + // GPluginNativePluginLoadFunc func; + // gboolean ret = FALSE; - if(GPLUGIN_IS_PLUGIN_INFO(info))
- name = gplugin_plugin_info_get_name(info);
+ // func = (GPluginNativePluginLoadFunc)priv->load_func; + // ret = func(native, &error); - g_warning(_("Could not reload previously loaded plugin '%s': %s\n"),
- name ? name : _("(unknown)"),
- error ? error->message : _("unknown"));
+ // g_warning("failed to load plugin: %s", error->message); - g_object_unref(G_OBJECT(info));
-gplugin_native_plugin_priv_unuse(GTypePlugin *plugin) {
- GPluginNativePlugin *native = GPLUGIN_NATIVE_PLUGIN(plugin);
- if(!gplugin_native_plugin_unuse(native, &error)) {
- GPluginPluginInfo *info =
- gplugin_plugin_get_info(GPLUGIN_PLUGIN(native));
- const gchar *name = NULL;
- if(GPLUGIN_IS_PLUGIN_INFO(info))
- name = gplugin_plugin_info_get_name(info);
- g_warning(_("Could not unuse plugin '%s': %s\n"),
- name ? name : _("(unknown)"),
- error ? error->message : _("unknown"));
- g_object_unref(G_OBJECT(info));
-gplugin_native_plugin_complete_type_info(GTypePlugin *plugin, GType type,
- GTypeValueTable *value_table)
- GPluginNativePlugin *native = GPLUGIN_NATIVE_PLUGIN(plugin);
- GPluginNativePluginTypeInfo *native_info =
- gplugin_native_plugin_find_type_info(native, type);
- *info = native_info->info;
- if(native_info->info.value_table)
- *value_table = *native_info->info.value_table;
-gplugin_native_plugin_complete_interface_info(GTypePlugin *plugin,
- GPluginNativePlugin *native = GPLUGIN_NATIVE_PLUGIN(plugin);
- GPluginNativePluginInterfaceInfo *iface_info =
- gplugin_native_plugin_find_interface_info(native, instance_type,
- *info = iface_info->info;
-gplugin_native_plugin_iface_init(GTypePluginClass *iface) {
- iface->use_plugin = gplugin_native_plugin_priv_use;
- iface->unuse_plugin = gplugin_native_plugin_priv_unuse;
- iface->complete_type_info = gplugin_native_plugin_complete_type_info;
- iface->complete_interface_info =
- gplugin_native_plugin_complete_interface_info;
+gplugin_native_plugin_unload(GTypeModule *module) { /******************************************************************************
@@ -238,6 +134,20 @@
g_value_set_pointer(value, priv->unload_func);
+ g_value_set_string(value, priv->filename); + g_value_set_object(value, priv->loader); + g_value_set_object(value, priv->info); + g_value_set_enum(value, priv->state); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -260,6 +170,21 @@
priv->unload_func = g_value_get_pointer(value);
+ priv->filename = g_strdup(g_value_get_string(value)); + priv->loader = g_object_ref(g_value_get_object(value)); + priv->info = g_object_ref(g_value_get_object(value)); + priv->state = g_value_get_enum(value); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -270,8 +195,9 @@
gplugin_native_plugin_finalize(GObject *obj) {
GPluginNativePluginPrivate *priv = gplugin_native_plugin_get_instance_private(GPLUGIN_NATIVE_PLUGIN(obj));
- g_slist_free(priv->type_infos);
- g_slist_free(priv->interface_infos);
+ g_free(priv->filename); + g_object_unref(G_OBJECT(priv->loader)); + g_object_unref(G_OBJECT(priv->info)); G_OBJECT_CLASS(gplugin_native_plugin_parent_class)->finalize(obj);
@@ -283,11 +209,15 @@
gplugin_native_plugin_class_init(GPluginNativePluginClass *klass) {
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+ GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS(klass); obj_class->finalize = gplugin_native_plugin_finalize;
obj_class->get_property = gplugin_native_plugin_get_property;
obj_class->set_property = gplugin_native_plugin_set_property;
+ module_class->load = gplugin_native_plugin_load; + module_class->unload = gplugin_native_plugin_unload; * GPluginNativePlugin:module:
@@ -322,322 +252,17 @@
g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
+ /* add our overrides */ + g_object_class_override_property(obj_class, PROP_FILENAME, "filename"); + g_object_class_override_property(obj_class, PROP_LOADER, "loader"); + g_object_class_override_property(obj_class, PROP_INFO, "info"); + g_object_class_override_property(obj_class, PROP_STATE, "state"); /******************************************************************************
*****************************************************************************/
- * gplugin_native_plugin_use:
- * @plugin: a #GPluginNativePlugin
- * @error: (out): return location for a #GError or null
- * Increments the ref count of @plugin by one.
- * See: g_type_module_use
- * Returns: FALSE if @plugin needed to be loaded and loading failed.
-gplugin_native_plugin_use(GPluginNativePlugin *plugin,
- GPLUGIN_UNUSED GError **error)
- GPluginNativePluginPrivate *priv = NULL;
- g_return_val_if_fail(GPLUGIN_IS_NATIVE_PLUGIN(plugin), FALSE);
- priv = gplugin_native_plugin_get_instance_private(plugin);
- if(priv->use_count == 1) {
- for(l = priv->type_infos; l; l = l->next) {
- GPluginNativePluginTypeInfo *info =
- (GPluginNativePluginTypeInfo *)(l->data);
- GPluginPluginInfo *plugin_info =
- gplugin_plugin_get_info(GPLUGIN_PLUGIN(plugin));
- const gchar *name = NULL;
- if(GPLUGIN_IS_PLUGIN_INFO(plugin_info))
- name = gplugin_plugin_info_get_name(plugin_info);
- g_warning(_("plugin '%s' failed to register type '%s'\n"),
- name, g_type_name(info->type));
- g_object_unref(G_OBJECT(plugin_info));
- * gplugin_native_plugin_unuse:
- * @plugin: a #GPluginNativePlugin
- * @error: (out): return location for a #GError or null
- * Decreases the ref count of @plugin by one. If the result is zero, @plugin
- * See: g_type_module_unuse
- * Returns: TRUE if successful, FALSE otherwise.
-gplugin_native_plugin_unuse(GPluginNativePlugin *plugin,
- GPLUGIN_UNUSED GError **error)
- GPluginNativePluginPrivate *priv = NULL;
- g_return_val_if_fail(GPLUGIN_IS_NATIVE_PLUGIN(plugin), FALSE);
- priv = gplugin_native_plugin_get_instance_private(plugin);
- g_return_val_if_fail(priv->use_count > 0, FALSE);
- if(priv->use_count == 0) {
- for(l = priv->type_infos; l; l = l->next) {
- GPluginNativePluginTypeInfo *info =
- (GPluginNativePluginTypeInfo *)(l->data);
- * gplugin_native_plugin_register_type:
- * @plugin: a #GPluginNativePlugin
- * @parent: the type for the parent class
- * @name: name for the type
- * @info: type information structure
- * @flags: flags field providing details about the type.
- * Looks up or registers a type that is implemented in @plugin.
- * See: g_type_module_register_type
- * Returns: the new or existing type ID
-gplugin_native_plugin_register_type(GPluginNativePlugin *plugin, GType parent,
- const gchar *name, const GTypeInfo *info,
- GPluginNativePluginPrivate *priv = NULL;
- GPluginNativePluginTypeInfo *type_info = NULL;
- GType type = G_TYPE_INVALID;
- g_return_val_if_fail(GPLUGIN_IS_NATIVE_PLUGIN(plugin), G_TYPE_INVALID);
- g_return_val_if_fail(name, G_TYPE_INVALID);
- g_return_val_if_fail(info, G_TYPE_INVALID);
- priv = gplugin_native_plugin_get_instance_private(plugin);
- type = g_type_from_name(name);
- if(type != G_TYPE_INVALID) {
- /* this type is already loaded, let's make sure it's the same plugin
- GTypePlugin *old = g_type_get_plugin(type);
- if(old != G_TYPE_PLUGIN(plugin)) {
- g_warning(_("Two different plugins tried to register '%s'"),
- /* The same plugin is reloading the type */
- type_info = gplugin_native_plugin_find_type_info(plugin, type);
- if(type_info->parent != parent) {
- /* eek, them bastards tried to reparent this type! */
- const gchar *parent_name = g_type_name(parent);
- g_warning(_("Type '%s' was recreated with a different parent type."
- "(was '%s', now '%s')"),
- name, g_type_name(type_info->parent),
- (parent_name) ? parent_name : _("unknown"));
- /* we need to free the old vtable if the old type had one */
- if(type_info->info.value_table)
- g_free((GTypeValueTable *)type_info->info.value_table);
- /* the type hasn't been loaded before, so now we need to add it */
- type_info = g_new(GPluginNativePluginTypeInfo, 1);
- type_info->parent = parent;
- type_info->type = g_type_register_dynamic(parent, name,
- priv->type_infos = g_slist_prepend(priv->type_infos, type_info);
- /* ok, now finish up */
- type_info->loaded = TRUE;
- type_info->info = *info;
- if(info->value_table) {
- type_info->info.value_table = g_memdup(info->value_table,
- sizeof(GTypeValueTable));
- if(g_type_is_a(type_info->type, GPLUGIN_TYPE_LOADER) &&
- !G_TYPE_IS_ABSTRACT(type_info->type))
- gplugin_manager_register_loader(type_info->type);
- return type_info->type;
- * gplugin_native_plugin_add_interface:
- * @plugin: a #GPluginNativePlugin
- * @instance_type: type to which to add the interface
- * @interface_type: interface type to add
- * @interface_info: type information structure
- * Registers an additional interface for a type that lives in @plugin.
- * See: g_type_module_add_interface
-gplugin_native_plugin_add_interface(GPluginNativePlugin *plugin,
- GType instance_type, GType interface_type,
- const GInterfaceInfo *interface_info)
- GPluginNativePluginPrivate *priv = NULL;
- GPluginNativePluginInterfaceInfo *iface_info = NULL;
- g_return_if_fail(GPLUGIN_IS_NATIVE_PLUGIN(plugin));
- g_return_if_fail(interface_info);
- priv = gplugin_native_plugin_get_instance_private(plugin);
- if(g_type_is_a(instance_type, interface_type)) {
- GTypePlugin *old = g_type_interface_get_plugin(instance_type,
- g_warning(_("Interface '%s' for '%s' was previously registered "
- "statically or for a parent type."),
- g_type_name(interface_type),
- g_type_name(instance_type));
- } else if(old != G_TYPE_PLUGIN(plugin)) {
- g_warning(_("Two different plugins tried to register interface "
- g_type_name(interface_type),
- g_type_name(instance_type));
- iface_info = gplugin_native_plugin_find_interface_info(plugin,
- g_return_if_fail(iface_info);
- iface_info = g_new0(GPluginNativePluginInterfaceInfo, 1);
- iface_info->instance_type = instance_type;
- iface_info->interface_type = interface_type;
- g_type_add_interface_dynamic(instance_type, interface_type,
- G_TYPE_PLUGIN(plugin));
- priv->interface_infos = g_slist_prepend(priv->interface_infos,
- iface_info->loaded = TRUE;
- iface_info->info = *interface_info;
- * gplugin_native_plugin_register_enum:
- * @plugin: a #GPluginNativePlugin
- * @name: a name for the type
- * @values: an array of %GEnumValue structs for the possible enumeration
- * values. The array is terminated by a struct with all members being
- * Looks up or registers a new enumeration named @name with the given @values,
- * and associates it with @plugin.
- * See: g_type_module_register_enum
- * Returns: the new or existing type ID.
-gplugin_native_plugin_register_enum(GPluginNativePlugin *plugin,
- const GEnumValue *values)
- g_return_val_if_fail(GPLUGIN_IS_NATIVE_PLUGIN(plugin), G_TYPE_INVALID);
- g_return_val_if_fail(name, G_TYPE_INVALID);
- g_return_val_if_fail(values, G_TYPE_INVALID);
- g_enum_complete_type_info(G_TYPE_ENUM, &enum_info, values);
- return gplugin_native_plugin_register_type(plugin, G_TYPE_ENUM, name,
- * gplugin_native_plugin_register_flags:
- * @plugin: a #GPluginNativePlugin
- * @name: name for the type
- * @values: an array of %GFlagValue structs for the possible flags values. The
- * array is terminated by a struct with all members being 0.
- * See: g_type_module_register_flags
- * Returns: the new or existing type ID.
-gplugin_native_plugin_register_flags(GPluginNativePlugin *plugin,
- const GFlagsValue *values)
- g_return_val_if_fail(GPLUGIN_IS_NATIVE_PLUGIN(plugin), G_TYPE_INVALID);
- g_return_val_if_fail(name, G_TYPE_INVALID);
- g_return_val_if_fail(values, G_TYPE_INVALID);
- g_flags_complete_type_info(G_TYPE_FLAGS, &flags_info, values);
- return gplugin_native_plugin_register_type(plugin, G_TYPE_FLAGS, name,
* gplugin_native_plugin_get_module: (skip)
--- a/gplugin/gplugin-native-plugin.h Mon Oct 08 00:55:11 2018 -0500
+++ b/gplugin/gplugin-native-plugin.h Mon Oct 08 20:27:16 2018 -0500
@@ -39,35 +39,23 @@
struct _GPluginNativePlugin {
- void (*_gplugin_reserved_1)(void);
- void (*_gplugin_reserved_2)(void);
- void (*_gplugin_reserved_3)(void);
- void (*_gplugin_reserved_4)(void);
struct _GPluginNativePluginClass {
- GPluginPluginClass parent;
+ GTypeModuleClass parent; - void (*_gplugin_reserved_1)(void);
- void (*_gplugin_reserved_2)(void);
- void (*_gplugin_reserved_3)(void);
- void (*_gplugin_reserved_4)(void);
GType gplugin_native_plugin_get_type(void);
-gboolean gplugin_native_plugin_use(GPluginNativePlugin *plugin, GError **error);
-gboolean gplugin_native_plugin_unuse(GPluginNativePlugin *plugin, GError **error);
-GType gplugin_native_plugin_register_type(GPluginNativePlugin *plugin, GType parent, const gchar *name, const GTypeInfo *info, GTypeFlags flags);
-void gplugin_native_plugin_add_interface(GPluginNativePlugin *plugin, GType instance_type, GType interface_type, const GInterfaceInfo *interface_info);
-GType gplugin_native_plugin_register_enum(GPluginNativePlugin *plugin, const gchar *name, const GEnumValue *values);
-GType gplugin_native_plugin_register_flags(GPluginNativePlugin *plugin, const gchar *name, const GFlagsValue *values);
GModule *gplugin_native_plugin_get_module(GPluginNativePlugin *plugin);
--- a/gplugin/gplugin-plugin.c Mon Oct 08 00:55:11 2018 -0500
+++ b/gplugin/gplugin-plugin.c Mon Oct 08 20:27:16 2018 -0500
@@ -45,231 +45,75 @@
/******************************************************************************
- *****************************************************************************/
- GPluginPluginInfo *info;
- GPluginPluginState state;
-/******************************************************************************
*****************************************************************************/
-static GParamSpec *properties[N_PROPERTIES] = {NULL,};
static guint signals[SIG_LAST] = {0, };
-G_DEFINE_TYPE_WITH_PRIVATE(GPluginPlugin, gplugin_plugin, G_TYPE_OBJECT);
-/******************************************************************************
- *****************************************************************************/
-gplugin_plugin_set_filename(GPluginPlugin *plugin, const gchar *filename) {
- GPluginPluginPrivate *priv = gplugin_plugin_get_instance_private(plugin);
- g_free(priv->filename);
- priv->filename = (filename) ? g_strdup(filename) : NULL;
- g_object_notify(G_OBJECT(plugin), "filename");
-gplugin_plugin_set_loader(GPluginPlugin *plugin, GPluginLoader *loader) {
- GPluginPluginPrivate *priv = gplugin_plugin_get_instance_private(plugin);
- g_object_unref(G_OBJECT(priv->loader));
- if(GPLUGIN_IS_LOADER(loader))
- priv->loader = GPLUGIN_LOADER(g_object_ref(G_OBJECT(loader)));
-gplugin_plugin_set_info(GPluginPlugin *plugin, GPluginPluginInfo *info) {
- GPluginPluginPrivate *priv = gplugin_plugin_get_instance_private(plugin);
- g_object_unref(G_OBJECT(priv->info));
- priv->info = GPLUGIN_PLUGIN_INFO(g_object_ref(G_OBJECT(info)));
-gplugin_plugin_get_internal_filename(GPluginPlugin *plugin) {
- GPluginPluginPrivate *priv = gplugin_plugin_get_instance_private(plugin);
-gplugin_plugin_add_dependent_plugin(GPluginPlugin *plugin,
- GPluginPlugin *dependent)
- GPluginPluginPrivate *priv = gplugin_plugin_get_instance_private(plugin);
- priv->dependents = g_list_append(priv->dependents, g_object_ref(dependent));
+G_DEFINE_INTERFACE(GPluginPlugin, gplugin_plugin, G_TYPE_INVALID); /******************************************************************************
*****************************************************************************/
-gplugin_plugin_get_property(GObject *obj, guint param_id, GValue *value,
- GPluginPlugin *plugin = GPLUGIN_PLUGIN(obj);
- g_value_set_string(value, gplugin_plugin_get_filename(plugin));
- g_value_take_object(value, gplugin_plugin_get_loader(plugin));
- g_value_take_object(value, gplugin_plugin_get_info(plugin));
- g_value_set_enum(value, gplugin_plugin_get_state(plugin));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-gplugin_plugin_set_property(GObject *obj, guint param_id, const GValue *value,
- GPluginPlugin *plugin = GPLUGIN_PLUGIN(obj);
- gplugin_plugin_set_filename(plugin, g_value_get_string(value));
- gplugin_plugin_set_loader(plugin, g_value_get_object(value));
- gplugin_plugin_set_info(plugin, g_value_get_object(value));
- gplugin_plugin_set_state(plugin, g_value_get_enum(value));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-gplugin_plugin_finalize(GObject *obj) {
- GPluginPluginPrivate *priv = gplugin_plugin_get_instance_private(GPLUGIN_PLUGIN(obj));
- g_free(priv->filename);
- g_object_unref(priv->loader);
- g_object_unref(G_OBJECT(priv->info));
- for(l = priv->dependents; l; l = l->next) {
- g_object_unref(G_OBJECT(l->data));
- G_OBJECT_CLASS(gplugin_plugin_parent_class)->finalize(obj);
-gplugin_plugin_init(GPluginPlugin *plugin) {
-gplugin_plugin_class_init(GPluginPluginClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- obj_class->get_property = gplugin_plugin_get_property;
- obj_class->set_property = gplugin_plugin_set_property;
- obj_class->finalize = gplugin_plugin_finalize;
+gplugin_plugin_default_init(GPluginPluginInterface *iface) { + GParamSpec *pspec = NULL; * GPluginPlugin:filename:
* The absolute path to the plugin on disk.
- properties[PROP_FILENAME] = g_param_spec_string(
+ pspec = g_param_spec_string( "The filename of the plugin",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
+ g_object_interface_install_property(iface, pspec); * The #GPluginLoader that loaded this plugin.
- properties[PROP_LOADER] = g_param_spec_object(
+ pspec = g_param_spec_object( "The loader for this plugin",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
+ g_object_interface_install_property(iface, pspec); * The #GPluginPluginInfo from this plugin.
- properties[PROP_INFO] = g_param_spec_object(
+ pspec = g_param_spec_object( "The information for the plugin",
GPLUGIN_TYPE_PLUGIN_INFO,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
+ g_object_interface_install_property(iface, pspec); * The #GPluginPluginState that this plugin is in.
- properties[PROP_STATE] = g_param_spec_enum(
+ pspec = g_param_spec_enum( "The state of the plugin",
GPLUGIN_TYPE_PLUGIN_STATE,
GPLUGIN_PLUGIN_STATE_UNKNOWN,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT
- /* install the properties */
- g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
+ g_object_interface_install_property(iface, pspec); * GPluginPlugin::state-changed:
@@ -281,9 +125,9 @@
signals[SIG_STATE_CHANGED] =
g_signal_new("state-changed",
- G_OBJECT_CLASS_TYPE(klass),
- G_STRUCT_OFFSET(GPluginPluginClass, state_changed),
+ G_STRUCT_OFFSET(GPluginPluginInterface, state_changed), gplugin_marshal_VOID__ENUM_ENUM,
@@ -301,17 +145,17 @@
* Returns the filename that @plugin was loaded from.
- * Returns: The filename of @plugin
+ * Returns: (transfer full): The filename of @plugin
gplugin_plugin_get_filename(GPluginPlugin *plugin) {
- GPluginPluginPrivate *priv = NULL;
+ gchar *filename = NULL; g_return_val_if_fail(GPLUGIN_IS_PLUGIN(plugin), NULL);
- priv = gplugin_plugin_get_instance_private(plugin);
+ g_object_get(G_OBJECT(plugin), "filename", &filename, NULL);
@@ -324,13 +168,13 @@
gplugin_plugin_get_loader(GPluginPlugin *plugin) {
- GPluginPluginPrivate *priv = NULL;
+ GPluginLoader *loader = NULL; g_return_val_if_fail(GPLUGIN_IS_PLUGIN(plugin), NULL);
- priv = gplugin_plugin_get_instance_private(plugin);
+ g_object_get(G_OBJECT(plugin), "loader", &loader, NULL); - return (priv->info) ? GPLUGIN_LOADER(g_object_ref(G_OBJECT(priv->loader))) : NULL;
@@ -343,13 +187,13 @@
gplugin_plugin_get_info(GPluginPlugin *plugin) {
- GPluginPluginPrivate *priv = NULL;
+ GPluginPluginInfo *info = NULL; g_return_val_if_fail(GPLUGIN_IS_PLUGIN(plugin), NULL);
- priv = gplugin_plugin_get_instance_private(plugin);
+ g_object_get(G_OBJECT(plugin), "info", &info, NULL); - return (priv->info) ? GPLUGIN_PLUGIN_INFO(g_object_ref(G_OBJECT(priv->info))) : NULL;
@@ -362,13 +206,13 @@
gplugin_plugin_get_state(GPluginPlugin *plugin) {
- GPluginPluginPrivate *priv = NULL;
+ GPluginPluginState state = GPLUGIN_PLUGIN_STATE_UNKNOWN; g_return_val_if_fail(GPLUGIN_IS_PLUGIN(plugin), GPLUGIN_PLUGIN_STATE_UNKNOWN);
- priv = gplugin_plugin_get_instance_private(plugin);
+ g_object_get(G_OBJECT(plugin), "state", &state, NULL);
@@ -381,36 +225,14 @@
gplugin_plugin_set_state(GPluginPlugin *plugin, GPluginPluginState state) {
- GPluginPluginPrivate *priv = NULL;
GPluginPluginState oldstate = GPLUGIN_PLUGIN_STATE_UNKNOWN;
g_return_if_fail(GPLUGIN_IS_PLUGIN(plugin));
- priv = gplugin_plugin_get_instance_private(plugin);
+ oldstate = gplugin_plugin_get_state(plugin); - oldstate = priv->state;
+ g_object_set(G_OBJECT(plugin), "state", state, NULL); g_signal_emit(plugin, signals[SIG_STATE_CHANGED], 0,
- oldstate, priv->state);
- * gplugin_plugin_get_dependent_plugins:
- * @plugin: #GPluginPlugin instance
- * Returns a list of plugins that depend on @plugin.
- * Returns: (element-type GPlugin.Plugin) (transfer none): A #GList of each
- * plugin that depends on this plugin.
-gplugin_plugin_get_dependent_plugins(GPluginPlugin *plugin) {
- GPluginPluginPrivate *priv = NULL;
- g_return_val_if_fail(GPLUGIN_IS_PLUGIN(plugin), NULL);
- priv = gplugin_plugin_get_instance_private(plugin);
- return priv->dependents;
--- a/gplugin/gplugin-plugin.h Mon Oct 08 00:55:11 2018 -0500
+++ b/gplugin/gplugin-plugin.h Mon Oct 08 20:27:16 2018 -0500
@@ -26,13 +26,11 @@
#define GPLUGIN_TYPE_PLUGIN (gplugin_plugin_get_type())
#define GPLUGIN_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GPLUGIN_TYPE_PLUGIN, GPluginPlugin))
-#define GPLUGIN_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GPLUGIN_TYPE_PLUGIN, GPluginPluginClass))
#define GPLUGIN_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GPLUGIN_TYPE_PLUGIN))
-#define GPLUGIN_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GPLUGIN_TYPE_PLUGIN))
-#define GPLUGIN_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GPLUGIN_TYPE_PLUGIN, GPluginPluginClass))
+#define GPLUGIN_PLUGIN_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), GPLUGIN_TYPE_PLUGIN, GPluginPluginInterface)) typedef struct _GPluginPlugin GPluginPlugin;
-typedef struct _GPluginPluginClass GPluginPluginClass;
+typedef struct _GPluginPluginInterface GPluginPluginInterface; typedef enum /*< prefix=GPLUGIN_PLUGIN_STATE,underscore_name=GPLUGIN_PLUGIN_STATE >*/ {
GPLUGIN_PLUGIN_STATE_UNKNOWN = -1,
@@ -52,32 +50,26 @@
#include <gplugin/gplugin-plugin-info.h>
#include <gplugin/gplugin-loader.h>
-struct _GPluginPluginClass {
+struct _GPluginPluginInterface { void (*state_changed)(GPluginPlugin *plugin, GPluginPluginState oldstate, GPluginPluginState newstate);
- void (*_gplugin_reserved_1)(void);
- void (*_gplugin_reserved_2)(void);
- void (*_gplugin_reserved_3)(void);
- void (*_gplugin_reserved_4)(void);
GType gplugin_plugin_get_type(void);
-const gchar *gplugin_plugin_get_filename(GPluginPlugin *plugin);
+gchar *gplugin_plugin_get_filename(GPluginPlugin *plugin); GPluginLoader *gplugin_plugin_get_loader(GPluginPlugin *plugin);
GPluginPluginInfo *gplugin_plugin_get_info(GPluginPlugin *plugin);
GPluginPluginState gplugin_plugin_get_state(GPluginPlugin *plugin);
void gplugin_plugin_set_state(GPluginPlugin *plugin, GPluginPluginState state);
-GList *gplugin_plugin_get_dependent_plugins(GPluginPlugin *plugin);
--- a/gplugin/gplugin-private.h Mon Oct 08 00:55:11 2018 -0500
+++ b/gplugin/gplugin-private.h Mon Oct 08 20:27:16 2018 -0500
@@ -32,15 +32,12 @@
-gchar *gplugin_plugin_get_internal_filename(GPluginPlugin *plugin);
void gplugin_manager_private_init(void);
void gplugin_manager_private_uninit(void);
gboolean gplugin_boolean_accumulator(GSignalInvocationHint *hint, GValue *return_accu, const GValue *handler_return, gpointer data);
gboolean gplugin_plugin_info_get_bind_local(GPluginPluginInfo *info);
-void gplugin_plugin_add_dependent_plugin(GPluginPlugin *plugin, GPluginPlugin *dependent);
--- a/gplugin/tests/dynamic-type/dynamic-type-provider.c Mon Oct 08 00:55:11 2018 -0500
+++ b/gplugin/tests/dynamic-type/dynamic-type-provider.c Mon Oct 08 20:27:16 2018 -0500
@@ -20,36 +20,20 @@
#include "dynamic-test.h"
-static GType type_real = 0;
+G_DEFINE_DYNAMIC_TYPE(DynamicTest, dynamic_test, G_TYPE_OBJECT); -dynamic_test_register_type(GPluginNativePlugin *plugin) {
- if(g_once_init_enter(&type_real)) {
- static const GTypeInfo info = {
- .class_size = sizeof(DynamicTestClass),
- .instance_size = sizeof(DynamicTest),
- type = gplugin_native_plugin_register_type(plugin,
- g_once_init_leave(&type_real, type);
+dynamic_test_init(DynamicTest *inst) { + g_message("instance created");
-dynamic_test_get_type(void) {
- if(G_UNLIKELY(type_real == 0)) {
- g_warning("dynamic_test_get_type was called before "
- "the type was registered!\n");
+dynamic_test_class_finalize(DynamicTestClass *klass) {
+dynamic_test_class_init(DynamicTestClass *klass) { + g_message("class created"); G_MODULE_EXPORT GPluginPluginInfo *
@@ -63,13 +47,7 @@
gplugin_load(GPluginNativePlugin *plugin, GError **error) {
- dynamic_test_register_type(plugin);
- *error = g_error_new(GPLUGIN_DOMAIN, 0,
- "type DynamicTest was not registered");
+ dynamic_test_register_type(G_TYPE_MODULE(plugin)); --- a/gplugin/tests/test-versioned-dependencies.c Mon Oct 08 00:55:11 2018 -0500
+++ b/gplugin/tests/test-versioned-dependencies.c Mon Oct 08 20:27:16 2018 -0500
@@ -30,20 +30,26 @@
GPluginPlugin *plugin = NULL;
+ GSList *deps = NULL, *l = NULL; plugin = gplugin_manager_find_plugin("gplugin/test-no-version");
g_assert_cmpint(gplugin_plugin_get_state(plugin), ==,
GPLUGIN_PLUGIN_STATE_LOADED);
- for(l = gplugin_plugin_get_dependent_plugins(plugin); l; l = l->next) {
- if(l->data == dependent)
+ deps = gplugin_manager_get_plugin_dependencies(plugin, NULL); + for(l = deps; l; l = l->next) { + if(l->data == dependent) { + g_slist_free_full(deps, g_object_unref);
g_object_unref(G_OBJECT(plugin));
--- a/lua/gplugin-lua-loader.c Mon Oct 08 00:55:11 2018 -0500
+++ b/lua/gplugin-lua-loader.c Mon Oct 08 20:27:16 2018 -0500
@@ -25,11 +25,7 @@
-/******************************************************************************
- *****************************************************************************/
-static GObjectClass *parent_class = NULL;
-static GType type_real = 0;
+G_DEFINE_DYNAMIC_TYPE(GPluginLuaLoader, gplugin_lua_loader, GPLUGIN_TYPE_LOADER); /******************************************************************************
@@ -171,7 +167,7 @@
plugin = g_object_new(GPLUGIN_TYPE_LUA_PLUGIN,
@@ -199,11 +195,17 @@
*****************************************************************************/
+gplugin_lua_loader_init(GPluginLuaLoader *loader) { +gplugin_lua_loader_class_finalize(GPluginLuaLoaderClass *klass) { gplugin_lua_loader_class_init(GPluginLuaLoaderClass *klass) {
GPluginLoaderClass *loader_class = GPLUGIN_LOADER_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
loader_class->supported_extensions =
gplugin_lua_loader_class_supported_extensions;
loader_class->query = gplugin_lua_loader_query;
@@ -216,32 +218,5 @@
*****************************************************************************/
gplugin_lua_loader_register(GPluginNativePlugin *plugin) {
- if(g_once_init_enter(&type_real)) {
- static const GTypeInfo info = {
- .class_size = sizeof(GPluginLuaLoaderClass),
- .class_init = (GClassInitFunc)gplugin_lua_loader_class_init,
- .instance_size = sizeof(GPluginLuaLoader),
- type = gplugin_native_plugin_register_type(plugin,
- g_once_init_leave(&type_real, type);
+ gplugin_lua_loader_register_type(G_TYPE_MODULE(plugin));
-gplugin_lua_loader_get_type(void) {
- if(G_UNLIKELY(type_real == 0)) {
- g_warning("gplugin_lua_loader_get_type was called before "
- "the type was registered!\n");
--- a/lua/gplugin-lua-loader.h Mon Oct 08 00:55:11 2018 -0500
+++ b/lua/gplugin-lua-loader.h Mon Oct 08 20:27:16 2018 -0500
@@ -32,21 +32,17 @@
#include <gplugin-native.h>
struct _GPluginLuaLoader {
- void (*_gplugin_reserved_1)(void);
- void (*_gplugin_reserved_2)(void);
- void (*_gplugin_reserved_3)(void);
- void (*_gplugin_reserved_4)(void);
struct _GPluginLuaLoaderClass {
GPluginLoaderClass parent;
- void (*_gplugin_reserved_1)(void);
- void (*_gplugin_reserved_2)(void);
- void (*_gplugin_reserved_3)(void);
- void (*_gplugin_reserved_4)(void);
--- a/lua/gplugin-lua-plugin.c Mon Oct 08 00:55:11 2018 -0500
+++ b/lua/gplugin-lua-plugin.c Mon Oct 08 20:27:16 2018 -0500
@@ -19,14 +19,16 @@
-#define GPLUGIN_LUA_PLUGIN_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), GPLUGIN_TYPE_LUA_PLUGIN, GPluginLuaPluginPrivate))
/******************************************************************************
*****************************************************************************/
+ GPluginPluginInfo *info; + GPluginPluginState state; } GPluginLuaPluginPrivate;
/******************************************************************************
@@ -34,22 +36,33 @@
*****************************************************************************/
+ PROP_FILENAME = N_PROPERTIES, static GParamSpec *properties[N_PROPERTIES] = {NULL,};
-static GObjectClass *parent_class = NULL;
-static GType type_real = 0;
+/* I hate forward declarations... */ +static void gplugin_lua_plugin_iface_init(GPluginPluginInterface *iface); +G_DEFINE_DYNAMIC_TYPE_EXTENDED( + G_ADD_PRIVATE_DYNAMIC(GPluginLuaPlugin) + G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_lua_plugin_iface_init) /******************************************************************************
+ * GPluginPlugin Implementation *****************************************************************************/
-gplugin_lua_plugin_set_state(GPluginLuaPlugin *plugin, lua_State *L) {
- GPluginLuaPluginPrivate *priv = GPLUGIN_LUA_PLUGIN_GET_PRIVATE(plugin);
+gplugin_lua_plugin_iface_init(GPluginPluginInterface *iface) { /******************************************************************************
@@ -60,12 +73,27 @@
GPluginLuaPlugin *plugin = GPLUGIN_LUA_PLUGIN(obj);
+ GPluginLuaPluginPrivate *priv = gplugin_lua_plugin_get_instance_private(plugin); + g_value_set_pointer(value, priv->L); + g_value_set_string(value, priv->filename); + g_value_set_object(value, priv->loader); + g_value_set_object(value, priv->info); - g_value_set_pointer(value,
- gplugin_lua_plugin_get_state(plugin));
+ g_value_set_enum(value, priv->state); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -77,12 +105,27 @@
const GValue *value, GParamSpec *pspec)
GPluginLuaPlugin *plugin = GPLUGIN_LUA_PLUGIN(obj);
+ GPluginLuaPluginPrivate *priv = gplugin_lua_plugin_get_instance_private(plugin); + priv->L = g_value_get_pointer(value); + priv->filename = g_strdup(g_value_get_string(value)); + priv->loader = g_object_ref(g_value_get_object(value)); + priv->info = g_object_ref(g_value_get_object(value)); - gplugin_lua_plugin_set_state(plugin,
- g_value_get_pointer(value));
+ priv->state = g_value_get_enum(value); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -91,12 +134,24 @@
gplugin_lua_plugin_finalize(GObject *obj) {
- GPluginLuaPluginPrivate *priv = GPLUGIN_LUA_PLUGIN_GET_PRIVATE(obj);
+ GPluginLuaPluginPrivate *priv = gplugin_lua_plugin_get_instance_private(GPLUGIN_LUA_PLUGIN(obj)); - G_OBJECT_CLASS(parent_class)->finalize(obj);
+ g_free(priv->filename); + g_object_unref(G_OBJECT(priv->loader)); + g_object_unref(G_OBJECT(priv->info)); + G_OBJECT_CLASS(gplugin_lua_plugin_parent_class)->finalize(obj); +gplugin_lua_plugin_init(GPluginLuaPlugin *plugin) { +gplugin_lua_plugin_class_finalize(GPluginLuaPluginClass *klass) { @@ -107,53 +162,36 @@
obj_class->set_property = gplugin_lua_plugin_set_property;
obj_class->finalize = gplugin_lua_plugin_finalize;
- properties[PROP_STATE] = g_param_spec_pointer(
+ properties[PROP_LUA_STATE] = g_param_spec_pointer( + "lua-state", "lua-state", "The lua state for the plugin",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
+ /* add our overrides */ + g_object_class_override_property(obj_class, PROP_FILENAME, "filename"); + g_object_class_override_property(obj_class, PROP_LOADER, "loader"); + g_object_class_override_property(obj_class, PROP_INFO, "info"); + g_object_class_override_property(obj_class, PROP_STATE, "state"); /******************************************************************************
*****************************************************************************/
-gplugin_lua_plugin_register(GPluginNativePlugin *plugin) {
- if(g_once_init_enter(&type_real)) {
- static const GTypeInfo info = {
- .class_size = sizeof(GPluginLuaPluginClass),
- .class_init = (GClassInitFunc)gplugin_lua_plugin_class_init,
- .instance_size = sizeof(GPluginLuaPlugin),
- type = gplugin_native_plugin_register_type(plugin,
- g_once_init_leave(&type_real, type);
-gplugin_lua_plugin_get_type(void) {
- if(G_UNLIKELY(type_real == 0)) {
- g_warning("gplugin_lua_plugin_get_type was called before "
- "the type was registered!\n");
+gplugin_lua_plugin_register(GPluginNativePlugin *native) { + gplugin_lua_plugin_register_type(G_TYPE_MODULE(native)); -gplugin_lua_plugin_get_state(const GPluginLuaPlugin *plugin) {
- GPluginLuaPluginPrivate *priv = GPLUGIN_LUA_PLUGIN_GET_PRIVATE(plugin);
+gplugin_lua_plugin_get_state(GPluginLuaPlugin *plugin) { + GPluginLuaPluginPrivate *priv = NULL; + g_return_val_if_fail(GPLUGIN_IS_LUA_PLUGIN(plugin), NULL); + priv = gplugin_lua_plugin_get_instance_private(plugin);
--- a/lua/gplugin-lua-plugin.h Mon Oct 08 00:55:11 2018 -0500
+++ b/lua/gplugin-lua-plugin.h Mon Oct 08 20:27:16 2018 -0500
@@ -34,24 +34,25 @@
struct _GPluginLuaPlugin {
struct _GPluginLuaPluginClass {
- GPluginPluginClass parent;
- void (*_gplugin_reserved_1)(void);
- void (*_gplugin_reserved_2)(void);
- void (*_gplugin_reserved_3)(void);
- void (*_gplugin_reserved_4)(void);
-void gplugin_lua_plugin_register(GPluginNativePlugin *plugin);
+void gplugin_lua_plugin_register(GPluginNativePlugin *native); GType gplugin_lua_plugin_get_type(void);
-lua_State *gplugin_lua_plugin_get_state(const GPluginLuaPlugin *plugin);
+lua_State *gplugin_lua_plugin_get_state(GPluginLuaPlugin *plugin); --- a/python/gplugin-python-loader.c Mon Oct 08 00:55:11 2018 -0500
+++ b/python/gplugin-python-loader.c Mon Oct 08 20:27:16 2018 -0500
@@ -28,25 +28,21 @@
-#define GPLUGIN_PYTHON_LOADER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), GPLUGIN_TYPE_PYTHON_LOADER, GPluginPythonLoaderPrivate))
-/******************************************************************************
- *****************************************************************************/
PyThreadState *py_thread_state;
} GPluginPythonLoaderPrivate;
-/******************************************************************************
- *****************************************************************************/
-static GObjectClass *parent_class = NULL;
-static GType type_real = 0;
+G_DEFINE_DYNAMIC_TYPE_EXTENDED( + G_ADD_PRIVATE_DYNAMIC(GPluginPythonLoader) /******************************************************************************
- * GPluginLoaderInterface API
+ * GPluginLoader Implementation *****************************************************************************/
gplugin_python_loader_class_supported_extensions(GPLUGIN_UNUSED const GPluginLoaderClass *klass) {
@@ -357,26 +353,16 @@
*****************************************************************************/
-gplugin_python_loader_finalize(GObject *obj) {
- GPluginPythonLoaderPrivate *priv =
- GPLUGIN_PYTHON_LOADER_GET_PRIVATE(obj);
+gplugin_python_loader_init(GPluginPythonLoader *loader) { - G_OBJECT_CLASS(parent_class)->finalize(obj);
+gplugin_python_loader_class_finalize(GPluginPythonLoaderClass *klass) { gplugin_python_loader_class_init(GPluginPythonLoaderClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- GPluginLoaderClass *loader_class =
- GPLUGIN_LOADER_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
- g_type_class_add_private(klass, sizeof(GPluginPythonLoaderPrivate));
- obj_class->finalize = gplugin_python_loader_finalize;
+ GPluginLoaderClass *loader_class = GPLUGIN_LOADER_CLASS(klass); loader_class->supported_extensions =
gplugin_python_loader_class_supported_extensions;
@@ -389,35 +375,9 @@
*****************************************************************************/
-gplugin_python_loader_register(GPluginNativePlugin *plugin) {
- if(g_once_init_enter(&type_real)) {
- static const GTypeInfo info = {
- .class_size = sizeof(GPluginPythonLoaderClass),
- .class_init = (GClassInitFunc)gplugin_python_loader_class_init,
- .instance_size = sizeof(GPluginPythonLoader),
+gplugin_python_loader_register(GPluginNativePlugin *native) { + gplugin_python_loader_register_type(G_TYPE_MODULE(native)); - type = gplugin_native_plugin_register_type(plugin,
- gplugin_python_loader_init_python();
- g_once_init_leave(&type_real, type);
+ gplugin_python_loader_init_python();
-gplugin_python_loader_get_type(void) {
- if(G_UNLIKELY(type_real == 0)) {
- g_warning("gplugin_python_loader_get_type was called before "
- "the type was registered!\n");
--- a/python/gplugin-python-loader.h Mon Oct 08 00:55:11 2018 -0500
+++ b/python/gplugin-python-loader.h Mon Oct 08 20:27:16 2018 -0500
@@ -32,26 +32,22 @@
#include <gplugin-native.h>
struct _GPluginPythonLoader {
- void (*_gplugin_reserved_1)(void);
- void (*_gplugin_reserved_2)(void);
- void (*_gplugin_reserved_3)(void);
- void (*_gplugin_reserved_4)(void);
struct _GPluginPythonLoaderClass {
GPluginLoaderClass parent;
- void (*_gplugin_reserved_1)(void);
- void (*_gplugin_reserved_2)(void);
- void (*_gplugin_reserved_3)(void);
- void (*_gplugin_reserved_4)(void);
-void gplugin_python_loader_register(GPluginNativePlugin *plugin);
+void gplugin_python_loader_register(GPluginNativePlugin *native); GType gplugin_python_loader_get_type(void);
--- a/python/gplugin-python-plugin.c Mon Oct 08 00:55:11 2018 -0500
+++ b/python/gplugin-python-plugin.c Mon Oct 08 20:27:16 2018 -0500
@@ -21,9 +21,6 @@
-#define GPLUGIN_PYTHON_PLUGIN_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), GPLUGIN_TYPE_PYTHON_PLUGIN, GPluginPythonPluginPrivate))
/******************************************************************************
*****************************************************************************/
@@ -32,6 +29,12 @@
+ GPluginPluginInfo *info; + GPluginPluginState state; } GPluginPythonPluginPrivate;
/******************************************************************************
@@ -43,22 +46,43 @@
+ PROP_FILENAME = N_PROPERTIES, static GParamSpec *properties[N_PROPERTIES] = {NULL,};
-static GObjectClass *parent_class = NULL;
-static GType type_real = 0;
+/* I hate forward declarations... */ +static void gplugin_python_plugin_iface_init(GPluginPluginInterface *iface); +G_DEFINE_DYNAMIC_TYPE_EXTENDED( + G_ADD_PRIVATE_DYNAMIC(GPluginPythonPlugin) + G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_python_plugin_iface_init) +/****************************************************************************** + * GPluginPlugin Implementation + *****************************************************************************/ +gplugin_python_plugin_iface_init(GPluginPluginInterface *iface) { /******************************************************************************
*****************************************************************************/
-gplugin_python_plugin_get_module(const GPluginPythonPlugin *plugin) {
+gplugin_python_plugin_get_module(GPluginPythonPlugin *plugin) { GPluginPythonPluginPrivate *priv = NULL;
g_return_val_if_fail(GPLUGIN_IS_PYTHON_PLUGIN(plugin), NULL);
- priv = GPLUGIN_PYTHON_PLUGIN_GET_PRIVATE(plugin);
+ priv = gplugin_python_plugin_get_instance_private(plugin); @@ -72,7 +96,7 @@
g_return_if_fail(GPLUGIN_IS_PLUGIN(plugin));
g_return_if_fail(module);
- priv = GPLUGIN_PYTHON_PLUGIN_GET_PRIVATE(plugin);
+ priv = gplugin_python_plugin_get_instance_private(plugin); @@ -84,12 +108,12 @@
-gplugin_python_plugin_get_load_func(const GPluginPythonPlugin *plugin) {
+gplugin_python_plugin_get_load_func(GPluginPythonPlugin *plugin) { GPluginPythonPluginPrivate *priv = NULL;
g_return_val_if_fail(GPLUGIN_IS_PYTHON_PLUGIN(plugin), NULL);
- priv = GPLUGIN_PYTHON_PLUGIN_GET_PRIVATE(plugin);
+ priv = gplugin_python_plugin_get_instance_private(plugin); @@ -103,7 +127,7 @@
g_return_if_fail(GPLUGIN_IS_PYTHON_PLUGIN(plugin));
g_return_if_fail(func != NULL);
- priv = GPLUGIN_PYTHON_PLUGIN_GET_PRIVATE(plugin);
+ priv = gplugin_python_plugin_get_instance_private(plugin); @@ -114,12 +138,12 @@
-gplugin_python_plugin_get_unload_func(const GPluginPythonPlugin *plugin) {
+gplugin_python_plugin_get_unload_func(GPluginPythonPlugin *plugin) { GPluginPythonPluginPrivate *priv = NULL;
g_return_val_if_fail(GPLUGIN_IS_PYTHON_PLUGIN(plugin), NULL);
- priv = GPLUGIN_PYTHON_PLUGIN_GET_PRIVATE(plugin);
+ priv = gplugin_python_plugin_get_instance_private(plugin); @@ -133,7 +157,7 @@
g_return_if_fail(GPLUGIN_IS_PYTHON_PLUGIN(plugin));
g_return_if_fail(func != NULL);
- priv = GPLUGIN_PYTHON_PLUGIN_GET_PRIVATE(plugin);
+ priv = gplugin_python_plugin_get_instance_private(plugin); @@ -151,6 +175,7 @@
GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj);
+ GPluginPythonPluginPrivate *priv = gplugin_python_plugin_get_instance_private(plugin); @@ -165,6 +190,21 @@
g_value_set_pointer(value,
gplugin_python_plugin_get_unload_func(plugin));
+ g_value_set_string(value, priv->filename); + g_value_set_object(value, priv->loader); + g_value_set_object(value, priv->info); + g_value_set_enum(value, priv->state); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -176,6 +216,7 @@
const GValue *value, GParamSpec *pspec)
GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj);
+ GPluginPythonPluginPrivate *priv = gplugin_python_plugin_get_instance_private(plugin); @@ -190,6 +231,21 @@
gplugin_python_plugin_set_unload_func(plugin,
g_value_get_pointer(value));
+ priv->filename = g_strdup(g_value_get_string(value)); + priv->loader = g_object_ref(g_value_get_object(value)); + priv->info = g_object_ref(g_value_get_object(value)); + priv->state = g_value_get_enum(value); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -198,8 +254,7 @@
gplugin_python_plugin_finalize(GObject *obj) {
- GPluginPythonPluginPrivate *priv =
- GPLUGIN_PYTHON_PLUGIN_GET_PRIVATE(obj);
+ GPluginPythonPluginPrivate *priv = gplugin_python_plugin_get_instance_private(GPLUGIN_PYTHON_PLUGIN(obj)); @@ -208,17 +263,25 @@
- G_OBJECT_CLASS(parent_class)->finalize(obj);
+ g_free(priv->filename); + g_object_unref(G_OBJECT(priv->loader)); + g_object_unref(G_OBJECT(priv->info)); + G_OBJECT_CLASS(gplugin_python_plugin_parent_class)->finalize(obj); +gplugin_python_plugin_init(GPluginPythonPlugin *plugin) { +gplugin_python_plugin_class_finalize(GPluginPythonPluginClass *klass) { gplugin_python_plugin_class_init(GPluginPythonPluginClass *klass) {
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
- g_type_class_add_private(klass, sizeof(GPluginPythonPluginPrivate));
obj_class->get_property = gplugin_python_plugin_get_property;
obj_class->set_property = gplugin_python_plugin_set_property;
obj_class->finalize = gplugin_python_plugin_finalize;
@@ -242,39 +305,18 @@
g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
+ /* add our overrides */ + g_object_class_override_property(obj_class, PROP_FILENAME, "filename"); + g_object_class_override_property(obj_class, PROP_LOADER, "loader"); + g_object_class_override_property(obj_class, PROP_INFO, "info"); + g_object_class_override_property(obj_class, PROP_STATE, "state"); /******************************************************************************
*****************************************************************************/
-gplugin_python_plugin_register(GPluginNativePlugin *plugin) {
- if(g_once_init_enter(&type_real)) {
- static const GTypeInfo info = {
- .class_size = sizeof(GPluginPythonPluginClass),
- .class_init = (GClassInitFunc)gplugin_python_plugin_class_init,
- .instance_size = sizeof(GPluginPythonPlugin),
- type = gplugin_native_plugin_register_type(plugin,
- g_once_init_leave(&type_real, type);
+gplugin_python_plugin_register(GPluginNativePlugin *native) { + gplugin_python_plugin_register_type(G_TYPE_MODULE(native));
-gplugin_python_plugin_get_type(void) {
- if(G_UNLIKELY(type_real == 0)) {
- g_warning("gplugin_python_plugin_get_type was called before "
- "the type was registered!\n");
--- a/python/gplugin-python-plugin.h Mon Oct 08 00:55:11 2018 -0500
+++ b/python/gplugin-python-plugin.h Mon Oct 08 20:27:16 2018 -0500
@@ -32,21 +32,22 @@
#include <gplugin-native.h>
struct _GPluginPythonPlugin {
struct _GPluginPythonPluginClass {
- GPluginPluginClass parent;
- void (*_gplugin_reserved_1)(void);
- void (*_gplugin_reserved_2)(void);
- void (*_gplugin_reserved_3)(void);
- void (*_gplugin_reserved_4)(void);
-void gplugin_python_plugin_register(GPluginNativePlugin *plugin);
+void gplugin_python_plugin_register(GPluginNativePlugin *native); GType gplugin_python_plugin_get_type(void);