Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Enables definition of default plugins #799

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/Kaleidoscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,38 @@ typedef kaleidoscope::Runtime_ Kaleidoscope_;
// Kaleidoscope in global namespace.
//
extern kaleidoscope::Runtime_ &Kaleidoscope;

// Have a list of plugins that are always added.
// Those plugins might be configured by macros defined at the top of the sketch.
// Plugins can thus be turned into complete no-ops.

// For the sketch compilation unit, we pretend that there is a NoOpPlugin
// symbol. This is intented to be passed to the KALEIDOSCOPE_INIT_PLUGINS(...)
// function macro. As no existing non-inline functions of this macro are called
// for this plugin instance, it does not hurt that the instance is not
// actually instanciated in no other compilation unit.
//
#ifdef KALEIDOSCOPE_SKETCH
namespace kaleidoscope {
extern Plugin NoOpPlugin; // This is on purpose not instanciated in any
// compilation unit.
} // namespace kaleidoscope
#endif

// Plugins leading the list passed to KALEIDOSCOPE_INIT_PLUGINS
//
// Note: As long as we do not actually pass a plugin to
// KALEIDOSCOPE_STANDARD_PLUGINS_START, we need to pass at least
// a no-op plugin to satisfy the interface. The NoOpPlugin
// can be replaced as soon as other plugins are added.
//
#define KALEIDOSCOPE_STANDARD_PLUGINS_START kaleidoscope::NoOpPlugin

// Plugins trailing the list passed to KALEIDOSCOPE_INIT_PLUGINS
//
// Note: As long as we do not actually pass a plugin to
// KALEIDOSCOPE_STANDARD_PLUGINS_END, we need to pass at least
// a no-op plugin to satisfy the interface. The NoOpPlugin
// can be replaced as soon as other plugins are added.
//
#define KALEIDOSCOPE_STANDARD_PLUGINS_END kaleidoscope::NoOpPlugin
12 changes: 12 additions & 0 deletions src/kaleidoscope_internal/event_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,20 @@
static kaleidoscope::EventHandlerResult apply(Args__&&... hook_args) { __NL__ \
__NL__ \
kaleidoscope::EventHandlerResult result; __NL__ \
__NL__ \
/* KALEIDOSCOPE_STANDARD_PLUGINS_START is defined in Kaleidoscope.h */ __NL__ \
/**/ __NL__ \
MAP(_INLINE_EVENT_HANDLER_FOR_PLUGIN, __NL__ \
KALEIDOSCOPE_STANDARD_PLUGINS_START) __NL__ \
__NL__ \
MAP(_INLINE_EVENT_HANDLER_FOR_PLUGIN, __VA_ARGS__) __NL__ \
__NL__ \
/* KALEIDOSCOPE_STANDARD_PLUGINS_END is defined in Kaleidoscope.h */ __NL__ \
/**/ __NL__ \
MAP(_INLINE_EVENT_HANDLER_FOR_PLUGIN, __NL__ \
KALEIDOSCOPE_STANDARD_PLUGINS_END) __NL__ \
__NL__ \
__NL__ \
return result; __NL__ \
} __NL__ \
}; __NL__ \
Expand Down