PluginsMacro

ceramic.macros.PluginsMacro (Class)

Macro for automatic plugin initialization in the Ceramic framework.

This macro discovers enabled plugins at compile-time based on compiler defines and generates code to initialize them. It provides a centralized way to initialize all plugins without manually maintaining a list.

How It Works

  1. Scans compiler defines for keys starting with plugin_
  2. Derives plugin class names from the define keys
  3. Checks if each plugin class exists and has a pluginInit() method
  4. Generates initialization calls for all valid plugins

Plugin Naming Convention

  • Define: plugin_<name> (e.g., plugin_spine, plugin_ui)
  • Class: <Name>Plugin (e.g., SpinePlugin, UiPlugin)
  • Special cases handled: imgui -> ImGuiPlugin

Example

// In your main application:
PluginsMacro.initPlugins();

// With -D plugin_spine -D plugin_ui, generates:
// @:privateAccess ceramic.SpinePlugin.pluginInit();
// @:privateAccess ceramic.UiPlugin.pluginInit();

Plugin Requirements

Plugins must:

  • Be in the ceramic package
  • Have a static pluginInit() method
  • Follow the naming convention
See: ceramic.App Where plugins are initialized during app startup

Static Members

addPluginsUsing(): Dynamic

Init macro that makes every enabled plugin's static extensions available directly on ceramic.Assets, so projects don't have to declare a using for each of them.

Must run as an init macro (--macro): @:using is resolved before build macros run, so adding the metadata from a build macro on Assets would have no effect.

Plugin classes are detected by looking for their source file on the classpath rather than by resolving the type, which would force Assets to be typed while these very classes reference it.

Returns
Dynamic

initPlugins(): Dynamic

Resolves plugin classes and generates initialization calls for each enabled plugin.

This macro examines compiler defines at compile-time to determine which plugins are enabled, then generates the appropriate initialization code. Plugin initialization calls are made with @:privateAccess to allow access to private pluginInit methods.

Returns Description
Dynamic Expression block containing all plugin initialization calls