macro_rules! object_event_handler {
($interface_name:ident {
$(
$function_js_name:literal: $function_rust_name:ident($event_type:ty);
)*
}) => {
impl<'env> $interface_name<'env> {
$(
pub fn $function_rust_name<F>(
&self,
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,
{
crate::vscode_sys::macros::event_handler_body! {
env,
handler,
self.inner,
$function_js_name,
$function_rust_name($event_type)
}
}
)*
}
};
}
pub(crate) use object_event_handler;