(&mut self, func: &Function, interface: Option<&WorldKey>)
| 730 | } |
| 731 | |
| 732 | fn generate_guest_import(&mut self, func: &Function, interface: Option<&WorldKey>) { |
| 733 | if self.r#gen.skip.contains(&func.name) { |
| 734 | return; |
| 735 | } |
| 736 | |
| 737 | self.generate_payloads("", func, interface); |
| 738 | |
| 739 | let async_ = self.r#gen.is_async(self.resolve, interface, func, true); |
| 740 | let mut sig = FnSig { |
| 741 | async_, |
| 742 | ..Default::default() |
| 743 | }; |
| 744 | if let Some(id) = func.kind.resource() { |
| 745 | let name = self.resolve.types[id].name.as_ref().unwrap(); |
| 746 | let name = to_upper_camel_case(name); |
| 747 | uwriteln!(self.src, "impl {name} {{"); |
| 748 | sig.use_item_name = true; |
| 749 | sig.update_for_func(&func); |
| 750 | } |
| 751 | self.src.push_str("#[allow(unused_unsafe, clippy::all)]\n"); |
| 752 | let params = self.print_signature(func, async_, &sig); |
| 753 | self.src.push_str("{\n"); |
| 754 | self.src.push_str("unsafe {\n"); |
| 755 | |
| 756 | if async_ { |
| 757 | self.generate_guest_import_body_async(&self.wasm_import_module, func, params); |
| 758 | } else { |
| 759 | self.generate_guest_import_body_sync(&self.wasm_import_module, func, params); |
| 760 | } |
| 761 | |
| 762 | self.src.push_str("}\n"); |
| 763 | self.src.push_str("}\n"); |
| 764 | |
| 765 | if func.kind.resource().is_some() { |
| 766 | self.src.push_str("}\n"); |
| 767 | } |
| 768 | } |
| 769 | |
| 770 | fn lower_to_memory(&mut self, address: &str, value: &str, ty: &Type, module: &str) -> String { |
| 771 | let mut f = FunctionBindgen::new(self, Vec::new(), module, true, false); |
no test coverage detected