use super::*;
pub fn register_native_action_bridge(bridge: fn(&str, &str, &str) -> bool) {
EXTERNAL_NATIVE_ACTION_BRIDGE.store(bridge as *mut (), Ordering::Release);
}
pub fn dispatch_native_action(kind: &str, arg1: &str, arg2: &str) -> bool {
let raw: *mut () = EXTERNAL_NATIVE_ACTION_BRIDGE.load(Ordering::Acquire);
if raw.is_null() {
return false;
}
let func: fn(&str, &str, &str) -> bool =
unsafe { transmute::<*mut (), fn(&str, &str, &str) -> bool>(raw) };
func(kind, arg1, arg2)
}
pub fn write_system_clipboard(text: &str) -> bool {
let bridge_ok: bool =
dispatch_native_action(NATIVE_ACTION_CLIPBOARD, CLIPBOARD_ACTION_WRITE, text);
#[cfg(target_os = "macos")]
{
macos_write_pasteboard(text) || bridge_ok
}
#[cfg(target_arch = "wasm32")]
{
web_write_clipboard(text) || bridge_ok
}
#[cfg(not(any(target_os = "macos", target_arch = "wasm32")))]
{
bridge_ok
}
}