#[macro_export]
macro_rules! export {
($function_type:ty, $call_path:path, $str:tt) => {
impl $crate::Funcktion for $function_type {
fn name(&self) -> &'static str {
$str
}
fn _call_internal(&self, req: $crate::Request) -> $crate::CallResult<$crate::Response> {
match std::panic::catch_unwind(|| $call_path(self, req)) {
Ok(r) => r,
Err(e) => Err($crate::CallError::new("FFI: caught unwinding panic")),
}
}
}
#[no_mangle]
pub extern "C" fn _funck_create() -> *mut $crate::Funcktion {
let constructor: fn() -> $function_type = <$function_type>::default;
let obj = constructor();
let boxed_obj: Box<$crate::Funcktion> = Box::new(obj);
Box::into_raw(boxed_obj)
}
};
}