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/Makefile.am b/Makefile.am
index 9a1c423..f45a87f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -90,6 +90,8 @@
 	libweston/noop-renderer.c			\
 	libweston/pixman-renderer.c			\
 	libweston/pixman-renderer.h			\
+	libweston/plugin-registry.c				\
+	libweston/plugin-registry.h				\
 	libweston/timeline.c				\
 	libweston/timeline.h				\
 	libweston/timeline-object.h			\
@@ -235,6 +237,7 @@
 	libweston/compositor-rdp.h		\
 	libweston/compositor-wayland.h		\
 	libweston/compositor-x11.h		\
+	libweston/plugin-registry.h		\
 	libweston/timeline-object.h		\
 	shared/matrix.h				\
 	shared/config-parser.h			\
@@ -1092,6 +1095,7 @@
 	zuctest
 
 module_tests =					\
+	plugin-registry-test.la			\
 	surface-test.la				\
 	surface-global-test.la
 
@@ -1143,6 +1147,10 @@
 test_module_ldflags = \
 	-module -avoid-version -rpath $(libdir) $(COMPOSITOR_LIBS)
 
+plugin_registry_test_la_SOURCES = tests/plugin-registry-test.c
+plugin_registry_test_la_LDFLAGS = $(test_module_ldflags)
+plugin_registry_test_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS)
+
 surface_global_test_la_SOURCES = tests/surface-global-test.c
 surface_global_test_la_LDFLAGS = $(test_module_ldflags)
 surface_global_test_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS)