Usually when writing a plugin I like to have keep the the loading/hooks code in
a single file (ex. `plugin.c`) and then having some kind of "context" object
code in a separate file, often implemented in OO-style (ex. constructor,
destructor, functions taking instance as first param, etc). The new plugin API
has been designed specifically to make this possible.
To further improve the new plugin API, this PR adds changes that reduce the
boilerplate needed to write an OO-style plugin (often GObject-based, but not
is to add a macro to make it simpler to register a GObject type of which an
instance is bound to the module loading/unloading lifetime.
(which is leading to the 3rd change), simply adds typedefs and better
documentation for the existing callback functions.
is to add a second set of callback functions which get passed the instance
data as the first parameter, in usual OO fashion. Typedefs are added to those
from the 2nd change to allow casting functions to the right type. I'm not super
fond of the `_swapped` prefix, but some kind of different name is required to
avoid breaking backwards compatibility.
Overall the changes are pretty trivial. I tested them using the code [in this
repo](https://github.com/codebrainz/geany-test-object-friendly). To see how
this improves the plugin code a little, see
where I modified a normal plugin to use the changes in this PR.
The changes are completely backwards compatible.
Note: these changes are a result of my [brain dump in these
You can view, comment on, or merge this pull request online at:
-- Commit Summary --
* Add helper macro to register module-scoped GObjects
* Add typedefs and more documentation for plugin funcs
* Add swapped plugin funcs, typedefs and documentation
-- File Changes --
M src/plugindata.h (185)
M src/plugins.c (39)
M src/pluginutils.c (11)
-- Patch Links --
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub: