(
&mut self,
func: &Function,
results: &[TypeId],
parameter_type: ParameterType,
)
| 676 | } |
| 677 | |
| 678 | fn gen_import_src( |
| 679 | &mut self, |
| 680 | func: &Function, |
| 681 | results: &[TypeId], |
| 682 | parameter_type: ParameterType, |
| 683 | ) -> (String, String) { |
| 684 | let mut bindgen = FunctionBindgen::new( |
| 685 | self, |
| 686 | func.item_name(), |
| 687 | &func.kind, |
| 688 | func.params |
| 689 | .iter() |
| 690 | .enumerate() |
| 691 | .map(|(i, Param { name, .. })| { |
| 692 | if i == 0 && matches!(&func.kind, FunctionKind::Method(_)) { |
| 693 | "this".to_owned() |
| 694 | } else { |
| 695 | name.to_csharp_ident() |
| 696 | } |
| 697 | }) |
| 698 | .collect(), |
| 699 | results.to_vec(), |
| 700 | parameter_type, |
| 701 | func.result, |
| 702 | ); |
| 703 | |
| 704 | let async_ = InterfaceGenerator::is_async(&func.kind); |
| 705 | let mut src: String; |
| 706 | |
| 707 | if async_ { |
| 708 | // TODO: Use lower_to_memory as per Go ? |
| 709 | let sig = bindgen |
| 710 | .interface_gen |
| 711 | .resolve |
| 712 | .wasm_signature(AbiVariant::GuestImportAsync, func); |
| 713 | |
| 714 | // TODO: the result is a tmp so could be result/1/2/.. Maybe this will fallout if we use lower_to_memory. |
| 715 | let async_status_var = "result"; // String::new(); |
| 716 | let requires_async_return_buffer_param = func.result.is_some(); |
| 717 | let async_return_buffer = if requires_async_return_buffer_param { |
| 718 | let buffer = bindgen.emit_allocation_for_type(&sig.results); |
| 719 | uwriteln!( |
| 720 | bindgen.src, |
| 721 | "//TODO: store somewhere with the TaskCompletionSource, possibly in the state, using Task.AsyncState to retrieve it later." |
| 722 | ); |
| 723 | Some(buffer) |
| 724 | } else { |
| 725 | None |
| 726 | }; |
| 727 | |
| 728 | let csharp_param_names = func |
| 729 | .params |
| 730 | .iter() |
| 731 | .map(|param| param.name.to_lower_camel_case()) |
| 732 | .collect::<Vec<_>>(); |
| 733 | |
| 734 | let (lower, wasm_params) = if sig.indirect_params { |
| 735 | todo!("indirect params not supported for async imports yet"); |
no test coverage detected