Skip to content

Commit

Permalink
add frontend name to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
takotori committed Jun 1, 2024
1 parent 7227216 commit 4e706a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
10 changes: 10 additions & 0 deletions src/utils/plugin_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ fn setup_frontend_plugins() -> Vec<FrontendPluginFunctions> {
PluginImplementation::Backend => continue,
PluginImplementation::Frontend => (),
}
let frontend_name: Result<
libloading::Symbol<unsafe extern "C" fn() -> String>,
libloading::Error,
> = lib.get(b"frontend_name");
let startup_frontend: Result<
libloading::Symbol<unsafe extern "C" fn() -> ()>,
libloading::Error,
Expand All @@ -203,18 +207,21 @@ fn setup_frontend_plugins() -> Vec<FrontendPluginFunctions> {
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,
tests_frontend,
) {
plugins.push(FrontendPluginFunctions::new(
capabilities.get_capabilities(),
frontend_name,
startup_frontend,
shutdown_frontend,
data_frontend,
Expand Down Expand Up @@ -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:
Expand All @@ -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<
Expand All @@ -299,6 +308,7 @@ impl FrontendPluginFunctions {
) -> Self {
Self {
capabilities,
frontend_name,
frontend_startup,
frontend_shutdown,
frontend_data,
Expand Down

0 comments on commit 4e706a8

Please sign in to comment.