everything_plugin/macros.rs
1/// ```ignore
2/// plugin_main!(App, {
3/// PluginHandler::builder()
4/// .name("Test Plugin")
5/// .description("A test plugin for Everything")
6/// .author("Chaoses-Ib")
7/// .version("0.1.0")
8/// .link("https://github.com/Chaoses-Ib/IbEverythingLib")
9/// .options_pages(vec![
10/// OptionsPage::builder()
11/// .name("Test Plugin")
12/// .load(ui::winio::spawn::<options::MainModel>)
13/// .build(),
14/// ])
15/// .build()
16/// });
17/// ```
18#[macro_export]
19macro_rules! plugin_main {
20 ($app_type:ty, $handler_builder:expr) => {
21 static HANDLER: ::std::sync::LazyLock<::everything_plugin::PluginHandler<$app_type>> =
22 ::std::sync::LazyLock::new(|| $handler_builder);
23
24 /// - `msg` is a `EVERYTHING_PLUGIN_PM_*` message.
25 /// - `data` will depend on the `EVERYTHING_PLUGIN_PM_*` message.
26 ///
27 /// return data based on the `EVERYTHING_PLUGIN_PM_*` message.
28 #[unsafe(no_mangle)]
29 pub extern "system" fn everything_plugin_proc(
30 msg: u32,
31 data: *mut ::std::ffi::c_void,
32 ) -> *mut ::std::ffi::c_void {
33 ::everything_plugin::PluginHandler::<$app_type>::handle_init_i18n(msg, data);
34
35 HANDLER.handle(msg, data)
36 }
37 };
38}