From 4e706a857b877c42dbfce2f9205eace8099338dc Mon Sep 17 00:00:00 2001 From: takotori Date: Sat, 1 Jun 2024 14:01:59 +0200 Subject: [PATCH] add frontend name to plugin --- Cargo.toml | 2 +- src/utils/plugin_setup.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e84ddaf..223bbe7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "re_set-lib" -version = "4.1.1" +version = "5.0.0" edition = "2021" description = "Data structure library for ReSet" repository = "https://github.com/Xetibo/ReSet-Lib" diff --git a/src/utils/plugin_setup.rs b/src/utils/plugin_setup.rs index c728bb7..1f00500 100644 --- a/src/utils/plugin_setup.rs +++ b/src/utils/plugin_setup.rs @@ -186,6 +186,10 @@ fn setup_frontend_plugins() -> Vec { PluginImplementation::Backend => continue, PluginImplementation::Frontend => (), } + let frontend_name: Result< + libloading::Symbol String>, + libloading::Error, + > = lib.get(b"frontend_name"); let startup_frontend: Result< libloading::Symbol ()>, libloading::Error, @@ -203,11 +207,13 @@ fn setup_frontend_plugins() -> Vec { libloading::Error, > = lib.get(b"frontend_tests"); if let ( + Ok(frontend_name), Ok(startup_frontend), Ok(shutdown_frontend), Ok(data_frontend), Ok(tests_frontend), ) = ( + frontend_name, startup_frontend, shutdown_frontend, data_frontend, @@ -215,6 +221,7 @@ fn setup_frontend_plugins() -> Vec { ) { plugins.push(FrontendPluginFunctions::new( capabilities.get_capabilities(), + frontend_name, startup_frontend, shutdown_frontend, data_frontend, @@ -278,6 +285,7 @@ unsafe impl Sync for BackendPluginFunctions {} #[allow(improper_ctypes_definitions)] pub struct FrontendPluginFunctions { pub capabilities: (Vec<&'static str>, bool), + pub frontend_name: libloading::Symbol<'static, unsafe extern "C" fn() -> String>, pub frontend_startup: libloading::Symbol<'static, unsafe extern "C" fn()>, pub frontend_shutdown: libloading::Symbol<'static, unsafe extern "C" fn()>, pub frontend_data: @@ -289,6 +297,7 @@ pub struct FrontendPluginFunctions { impl FrontendPluginFunctions { pub fn new( capabilities: (Vec<&'static str>, bool), + frontend_name: libloading::Symbol<'static, unsafe extern "C" fn() -> String>, frontend_startup: libloading::Symbol<'static, unsafe extern "C" fn()>, frontend_shutdown: libloading::Symbol<'static, unsafe extern "C" fn()>, frontend_data: libloading::Symbol< @@ -299,6 +308,7 @@ impl FrontendPluginFunctions { ) -> Self { Self { capabilities, + frontend_name, frontend_startup, frontend_shutdown, frontend_data,