---
source: crates/aviutl2-macros/src/module_functions.rs
expression: format_tokens(output)
---
impl MyModule {
    fn my_function(&self, fuga: f64) -> f64 {
        fuga * 2.0
    }
}
::aviutl2::__internal_module! {
    impl ::aviutl2::module::ScriptModuleFunctions for MyModule {
        fn functions() -> Vec<::aviutl2::module::ModuleFunction> {
            let mut functions = Vec::new();
            functions.push(::aviutl2::module::ModuleFunction {
                name: "my_function".to_string(),
                func: bridge_my_function,
            });
            return functions;
            extern "C" fn bridge_my_function(
                smp: *mut ::aviutl2::sys::module2::SCRIPT_MODULE_PARAM,
            ) {
                if let Err(panic_info) = ::aviutl2::__catch_unwind_with_panic_info(|| {
                    let mut __handle =
                        unsafe { ::aviutl2::module::ScriptModuleCallHandle::from_raw(smp) };
                    <MyModule as ::aviutl2::module::ScriptModule>::with_instance(
                        |__internal_self| {
                            let fuga: f64 =
                                match <f64 as ::aviutl2::module::FromScriptModuleParam>::from_param(
                                    &__handle, 0usize,
                                ) {
                                    ::std::option::Option::Some(value) => value,
                                    ::std::option::Option::None => {
                                        let _ = __handle.set_error(&format!(
                                            "Failed to convert parameter #{} to {}",
                                            0usize,
                                            stringify!(f64)
                                        ));
                                        return;
                                    }
                                };
                            let fn_result = <MyModule>::my_function(__internal_self, fuga);
                            ::aviutl2::module::__push_return_value(&mut __handle, fn_result);
                        },
                    );
                }) {
                    ::aviutl2::tracing::error!(
                        "Panic occurred during {}: {}",
                        "my_function",
                        panic_info
                    );
                    let _ = ::aviutl2::logger::write_error_log(&panic_info);
                }
            }
        }
    }
}
