compositor: add plugin-registry

Implement a simple register and lookup for function tables. This is
intended for plugins to expose APIs to other plugins.

It has been very hard to arrange a plugin to be able to call into
another plugin without modifying Weston core to explicitly support each
case. This patch fixes that.

The tests all pass.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 37d94ec..113f5fc 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -61,6 +61,7 @@
 #include "shared/timespec-util.h"
 #include "git-version.h"
 #include "version.h"
+#include "plugin-registry.h"
 
 #define DEFAULT_REPAINT_WINDOW 7 /* milliseconds */
 
@@ -4702,6 +4703,8 @@
 	wl_list_init(&ec->axis_binding_list);
 	wl_list_init(&ec->debug_binding_list);
 
+	wl_list_init(&ec->plugin_api_list);
+
 	weston_plane_init(&ec->primary_plane, ec, 0, 0);
 	weston_compositor_stack_plane(ec, &ec->primary_plane, NULL);
 
@@ -4947,6 +4950,9 @@
 
 	if (compositor->backend)
 		compositor->backend->destroy(compositor);
+
+	weston_plugin_api_destroy_list(compositor);
+
 	free(compositor);
 }