After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 767223 - Allow extensions to be an Abstract Base Class
Allow extensions to be an Abstract Base Class
Status: RESOLVED FIXED
Product: libpeas
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: libpeas-maint
libpeas-maint
Depends on:
Blocks:
 
 
Reported: 2016-06-03 22:04 UTC by Garrett Regier
Modified: 2017-03-25 04:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Allow extensions to be an Abstract Base Class (53.08 KB, patch)
2017-03-24 19:42 UTC, Garrett Regier
committed Details | Review

Description Garrett Regier 2016-06-03 22:04:40 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
Comment 1 Christian Hergert 2016-10-03 23:27:41 UTC
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.
Comment 2 Garrett Regier 2017-03-24 19:42:28 UTC
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.
Comment 3 Christian Hergert 2017-03-24 22:37:11 UTC
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
Comment 4 Garrett Regier 2017-03-25 03:20:37 UTC
(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.
Comment 5 Garrett Regier 2017-03-25 04:29:37 UTC
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.