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(|| {
23 ::everything_plugin::PluginHandler::<$app_type>::handle_init_i18n(
24 ::everything_plugin::sys::EVERYTHING_PLUGIN_PM_INIT,
25 0 as _,
26 );
27
28 $handler_builder
29 });
30
31 /// - `msg` is a `EVERYTHING_PLUGIN_PM_*` message.
32 /// - `data` will depend on the `EVERYTHING_PLUGIN_PM_*` message.
33 ///
34 /// return data based on the `EVERYTHING_PLUGIN_PM_*` message.
35 #[unsafe(no_mangle)]
36 pub extern "system" fn everything_plugin_proc(
37 msg: u32,
38 data: *mut ::std::ffi::c_void,
39 ) -> *mut ::std::ffi::c_void {
40 ::everything_plugin::PluginHandler::<$app_type>::handle_init_i18n(msg, data);
41
42 HANDLER.handle(msg, data)
43 }
44 };
45}