GNOME Bugzilla – Bug 767223
Allow extensions to be an Abstract Base Class
Last modified: 2017-03-25 04:29:37 UTC
This would remove the requirement that extensions implement the various properties manually. It would also avoid some interface performance overhead. Currently this is already possible and done by libpeas itself with PeasPluginLoader, the various type checks just need to be modified to allow both everywhere and update the documentation. [1] GNOME-Builder's extensions instead pass what could be properties via the interface's vfuncs to avoid implementing the properties manually multiple times. [2] However, this would negate a useful property of interfaces which is that an unlimited number of vfuncs can be added over time. With an abstract base class the number of additional vfuncs is limited to amount of padding in the class structure. Although this can be emulated with by creating a signal instead for some performance penalty. [3] 1. https://git.gnome.org/browse/libpeas/tree/libpeas/peas-object-module.c#n658 2. https://git.gnome.org/browse/gnome-builder/tree/libide/ide-application-addin.h 3. https://developer.gnome.org/gobject/unstable/gobject-Signals.html#g-signal-new-class-handler
The main reason Builder uses interfaces with various vfunc parameters is to reduce the amount of boilerplate for properties in plugins. So allowing abstract base classes (which can actually implement properties) would allow us more flexibility in API design.
Created attachment 348669 [details] [review] Allow extensions to be an Abstract Base Class This also includes a rather simple test case, but realistically nothing else is probably be required.
Review of attachment 348669 [details] [review]: This looks good to me. Is it the case that find_base_type_and_interfaces() now detects properties from the pre-requisites (so we would get :context from IdeObject in Builder)? If that is the case, I can remove my hack that we do in https://git.gnome.org/browse/gnome-builder/tree/libide/plugins/ide-extension-util.c#n105
(In reply to Christian Hergert from comment #3) > Review of attachment 348669 [details] [review] [review]: > > This looks good to me. Is it the case that find_base_type_and_interfaces() > now detects properties from the pre-requisites (so we would get :context > from IdeObject in Builder)? If that is the case, I can remove my hack that > we do in > https://git.gnome.org/browse/gnome-builder/tree/libide/plugins/ide-extension- > util.c#n105 That requires pushing the patch for Bug 762899, however this patch is based on that one.
This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.