macro_rules! namespace_event_handler {
($namespace:literal {
$(
$function_js_name:literal: $function_rust_name:ident($event_type:ty);
)*
}) => {
$(
pub fn $function_rust_name<F>(
env: &napi::Env,
handler: F,
// TODO: generic errors
) -> Result<(), napi::Error>
where
F: for<'function_context> Fn(
&'function_context napi::Env,
$event_type,
) -> Result<(), napi::Error>
+ std::panic::RefUnwindSafe
+ 'static,
{
let vscode_object = super::VscodeContext::vscode(env)?;
let event_container: bindgen_prelude::Object =
vscode_object.get_named_property($namespace)?;
crate::vscode_sys::macros::event_handler_body! {
env,
handler,
event_container,
$function_js_name,
$function_rust_name($event_type)
}
}
)*
};
}
pub(crate) use namespace_event_handler;