Use namespaces for all of the vala and genie plugins.
This was discovered when I loaded the vala and native test plugins at the same
time in gplugin query and they both tried to register types with the same
names.
Testing Done:
Ran unit tests and `gplugin-query` with all of the loaders and test plugins queryable.
Reviewed at https://reviews.imfreedom.org/r/984/
--- a/gplugin/reference/genie.md Thu Sep 30 17:03:43 2021 -0500
+++ b/gplugin/reference/genie.md Sat Oct 02 19:29:55 2021 -0500
@@ -8,38 +8,41 @@
-Like all plugins in GPlugin, Genie plugins must also implement the
-`gplugin_query`, `gplugin_load`, and `gplugin_unload` functions.
+Due to the way `GPlugin.PluginInfo` info works, you must subclass it and set +your values in the new constructor. It is recommended that you define this +class in a namespace to avoid collisions with other plugins. -Due to the way `GPlugin.PluginInfo` info works, you must subclass it and set
-your values in the new constructor.
+Like all plugins in GPlugin, Genie plugins must also implement the +`gplugin_query`, `gplugin_load`, and `gplugin_unload` functions. These +functions must be in the global namespace. The following is a basic Genie plugin.
-class BasicPluginInfo : GPlugin.PluginInfo
- authors : array of string = {"author1"}
+ class Info : GPlugin.PluginInfo + authors : array of string = {"author1"}
- id: "gplugin/genie-basic-plugin",
- abi_version: 0x01020304,
- description: "description"
+ id: "gplugin/genie-basic-plugin", + abi_version: 0x01020304, + description: "description" def gplugin_query(out error : Error) : GPlugin.PluginInfo
- return new BasicPluginInfo()
+ return new BasicPlugin.Info() def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
--- a/gplugin/reference/vala.md Thu Sep 30 17:03:43 2021 -0500
+++ b/gplugin/reference/vala.md Sat Oct 02 19:29:55 2021 -0500
@@ -8,19 +8,23 @@
-Like all plugins in GPlugin, Vala plugins must also implement the
-`gplugin_query`, `gplugin_load`, and `gplugin_unload` functions.
+Due to the way `GPlugin.PluginInfo` info works, you must subclass it and set +your values in the new constructor. It is recommended that you define this +class in a namespace to avoid collisions with other plugins. -Due to the way `GPlugin.PluginInfo` info works, you must subclass it and set
-your values in the new constructor.
+Like all plugins in GPlugin, Vala plugins must also implement the +`gplugin_query`, `gplugin_load`, and `gplugin_unload` functions. These +functions must be in the global namespace. The following is a basic Vala plugin.
-public class BasicPluginInfo : GPlugin.PluginInfo {
- public BasicPluginInfo() {
+public class Info : GPlugin.PluginInfo { string[] authors = {"author1"};
@@ -38,10 +42,12 @@
public GPlugin.PluginInfo gplugin_query(out Error error) {
- return new BasicPluginInfo();
+ return new BasicPlugin.Info(); public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
--- a/vala/tests/genie-plugins/basic.gs Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/genie-plugins/basic.gs Sat Oct 02 19:29:55 2021 -0500
@@ -16,27 +16,28 @@
-class BasicPluginInfo : GPlugin.PluginInfo
- authors : array of string = {"author1"}
+namespace GenieBasicPlugin + class Info : GPlugin.PluginInfo + authors : array of string = {"author1"}
- id: "gplugin/genie-basic-plugin",
- abi_version: 0x01020304,
- description: "description"
+ id: "gplugin/genie-basic-plugin", + abi_version: 0x01020304, + description: "description" def gplugin_query(out error : Error) : GPlugin.PluginInfo
- return new BasicPluginInfo()
+ return new GenieBasicPlugin.Info() def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
if not(plugin isa GPlugin.Plugin)
--- a/vala/tests/genie-plugins/dependent.gs Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/genie-plugins/dependent.gs Sat Oct 02 19:29:55 2021 -0500
@@ -16,19 +16,20 @@
-class DependentPluginInfo : GPlugin.PluginInfo
- dependencies : array of string = {"dependency1", "dependency2"}
+namespace GenieDependentPlugin + class Info : GPlugin.PluginInfo + dependencies : array of string = {"dependency1", "dependency2"}
- id: "gplugin/genie-dependent-plugin",
- dependencies: dependencies
+ id: "gplugin/genie-dependent-plugin", + dependencies: dependencies def gplugin_query(out error : Error) : GPlugin.PluginInfo
- return new DependentPluginInfo()
+ return new GenieDependentPlugin.Info() def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
--- a/vala/tests/genie-plugins/load-exception.gs Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/genie-plugins/load-exception.gs Sat Oct 02 19:29:55 2021 -0500
@@ -16,16 +16,17 @@
-class LoadExceptionPluginInfo : GPlugin.PluginInfo
- id: "gplugin/genie-load-exception"
+namespace GenieLoadExceptionPlugin + class Info : GPlugin.PluginInfo + id: "gplugin/genie-load-exception" def gplugin_query(out error : Error) : GPlugin.PluginInfo
- return new LoadExceptionPluginInfo()
+ return new GenieLoadExceptionPlugin.Info() def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
error = new Error(Quark.from_string("gplugin"), 0, "explode")
--- a/vala/tests/genie-plugins/load-failed.gs Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/genie-plugins/load-failed.gs Sat Oct 02 19:29:55 2021 -0500
@@ -16,16 +16,17 @@
-class LoadFailedPluginInfo : GPlugin.PluginInfo
- id: "gplugin/genie-load-failed"
+namespace LoadFailedPlugin + class Info : GPlugin.PluginInfo + id: "gplugin/genie-load-failed" def gplugin_query(out error : Error) : GPlugin.PluginInfo
- return new LoadFailedPluginInfo()
+ return new LoadFailedPlugin.Info() def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
--- a/vala/tests/genie-plugins/unload-failed.gs Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/genie-plugins/unload-failed.gs Sat Oct 02 19:29:55 2021 -0500
@@ -16,16 +16,17 @@
-class UnloadFailedPluginInfo : GPlugin.PluginInfo
- id: "gplugin/genie-unload-failed"
+namespace UnloadFailedPlugin + class Info : GPlugin.PluginInfo + id: "gplugin/genie-unload-failed" def gplugin_query(out error : Error) : GPlugin.PluginInfo
- return new UnloadFailedPluginInfo()
+ return new UnloadFailedPlugin.Info() def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
--- a/vala/tests/genie-plugins/unload-shutdown.gs Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/genie-plugins/unload-shutdown.gs Sat Oct 02 19:29:55 2021 -0500
@@ -17,11 +17,12 @@
-class UnloadShutdownPluginInfo : GPlugin.PluginInfo
- id: "gplugin/genie-unload-shutdown"
+namespace UnloadShutdownPlugin + class Info : GPlugin.PluginInfo + id: "gplugin/genie-unload-shutdown" @@ -29,7 +30,7 @@
def gplugin_query(out error : Error) : GPlugin.PluginInfo
- return new UnloadShutdownPluginInfo()
+ return new UnloadShutdownPlugin.Info() def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
--- a/vala/tests/plugins/basic.vala Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/plugins/basic.vala Sat Oct 02 19:29:55 2021 -0500
@@ -16,8 +16,10 @@
-public class BasicPluginInfo : GPlugin.PluginInfo {
- public BasicPluginInfo() {
+namespace ValaBasicPlugin { +public class Info : GPlugin.PluginInfo { string[] authors = {"author1"};
@@ -35,10 +37,12 @@
public GPlugin.PluginInfo gplugin_query(out Error error) {
- return new BasicPluginInfo();
+ return new ValaBasicPlugin.Info(); public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
--- a/vala/tests/plugins/dependent.vala Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/plugins/dependent.vala Sat Oct 02 19:29:55 2021 -0500
@@ -16,8 +16,10 @@
-public class DependentPluginInfo : GPlugin.PluginInfo {
- public DependentPluginInfo() {
+namespace ValaDependentPlugin { +public class Info : GPlugin.PluginInfo { string[] dependencies = {"dependency1", "dependency2"};
@@ -27,10 +29,12 @@
public GPlugin.PluginInfo gplugin_query(out Error error) {
- return new DependentPluginInfo();
+ return new ValaDependentPlugin.Info(); public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
--- a/vala/tests/plugins/load-exception.vala Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/plugins/load-exception.vala Sat Oct 02 19:29:55 2021 -0500
@@ -16,18 +16,22 @@
-public class LoadExceptionPluginInfo : GPlugin.PluginInfo {
- public LoadExceptionPluginInfo() {
+namespace ValaLoadExceptionPlugin { +public class Info : GPlugin.PluginInfo { id: "gplugin/vala-load-exception"
public GPlugin.PluginInfo gplugin_query(out Error error) {
- return new LoadExceptionPluginInfo();
+ return new ValaLoadExceptionPlugin.Info(); public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
--- a/vala/tests/plugins/load-failed.vala Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/plugins/load-failed.vala Sat Oct 02 19:29:55 2021 -0500
@@ -16,18 +16,22 @@
-public class LoadFailedPluginInfo : GPlugin.PluginInfo {
- public LoadFailedPluginInfo() {
+namespace ValaLoadFailedPlugin { +public class Info : GPlugin.PluginInfo { id: "gplugin/vala-load-failed"
public GPlugin.PluginInfo gplugin_query(out Error error) {
- return new LoadFailedPluginInfo();
+ return new ValaLoadFailedPlugin.Info(); public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
--- a/vala/tests/plugins/unload-failed.vala Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/plugins/unload-failed.vala Sat Oct 02 19:29:55 2021 -0500
@@ -16,18 +16,22 @@
-public class UnloadFailedPluginInfo : GPlugin.PluginInfo {
- public UnloadFailedPluginInfo() {
+namespace ValaUnloadFailed { +public class Info : GPlugin.PluginInfo { id: "gplugin/vala-unload-failed"
public GPlugin.PluginInfo gplugin_query(out Error error) {
- return new UnloadFailedPluginInfo();
+ return new ValaUnloadFailed.Info(); public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
--- a/vala/tests/plugins/unload-shutdown.vala Thu Sep 30 17:03:43 2021 -0500
+++ b/vala/tests/plugins/unload-shutdown.vala Sat Oct 02 19:29:55 2021 -0500
@@ -16,18 +16,22 @@
-public class UnloadShutdownPluginInfo : GPlugin.PluginInfo {
- public UnloadShutdownPluginInfo() {
+namespace ValaShutdownPlugin { +public class Info : GPlugin.PluginInfo { id: "gplugin/vala-unload-shutdown"
public GPlugin.PluginInfo gplugin_query(out Error error) {
- return new UnloadShutdownPluginInfo();
+ return new ValaShutdownPlugin.Info(); public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {