(&mut self, func: &Function, interface_key: Option<&WorldKey>)
| 840 | } |
| 841 | |
| 842 | pub(crate) fn export(&mut self, func: &Function, interface_key: Option<&WorldKey>) { |
| 843 | let camel_name = match &func.kind { |
| 844 | FunctionKind::Freestanding |
| 845 | | FunctionKind::Static(_) |
| 846 | | FunctionKind::AsyncFreestanding |
| 847 | | FunctionKind::AsyncStatic(_) => func.item_name().to_upper_camel_case(), |
| 848 | FunctionKind::Method(_) | FunctionKind::AsyncMethod(_) => { |
| 849 | func.item_name().to_upper_camel_case() |
| 850 | } |
| 851 | FunctionKind::Constructor(id) => { |
| 852 | self.csharp_gen.all_resources[id].name.to_upper_camel_case() |
| 853 | } |
| 854 | }; |
| 855 | |
| 856 | let modifiers = modifiers(func, &camel_name, Direction::Export); |
| 857 | |
| 858 | let sig = self.resolve.wasm_signature(AbiVariant::GuestExport, func); |
| 859 | |
| 860 | let (result_type, results) = self.func_payload_and_return_type(func); |
| 861 | |
| 862 | let mut bindgen = FunctionBindgen::new( |
| 863 | self, |
| 864 | func.item_name(), |
| 865 | &func.kind, |
| 866 | (0..sig.params.len()).map(|i| format!("p{i}")).collect(), |
| 867 | results, |
| 868 | ParameterType::ABI, |
| 869 | func.result, |
| 870 | ); |
| 871 | |
| 872 | let async_ = matches!( |
| 873 | func.kind, |
| 874 | FunctionKind::AsyncFreestanding |
| 875 | | FunctionKind::AsyncStatic(_) |
| 876 | | FunctionKind::AsyncMethod(_) |
| 877 | ); |
| 878 | |
| 879 | abi::call( |
| 880 | bindgen.interface_gen.resolve, |
| 881 | AbiVariant::GuestExport, |
| 882 | LiftLower::LiftArgsLowerResults, |
| 883 | func, |
| 884 | &mut bindgen, |
| 885 | async_, |
| 886 | ); |
| 887 | |
| 888 | let src = bindgen.src; |
| 889 | let resource_type_name = bindgen.resource_type_name; |
| 890 | |
| 891 | let vars = bindgen |
| 892 | .resource_drops |
| 893 | .iter() |
| 894 | .map(|(t, v)| format!("{t}? {v} = null;")) |
| 895 | .collect::<Vec<_>>() |
| 896 | .join(";\n"); |
| 897 | |
| 898 | let wasm_result_type = if async_ { |
| 899 | "int" |
no test coverage detected