MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / declare_import

Method declare_import

crates/cpp/src/lib.rs:1759–1782  ·  view source on GitHub ↗
(
        &mut self,
        module_name: &str,
        name: &str,
        params: &[WasmType],
        results: &[WasmType],
    )

Source from the content-addressed store, hash-verified

1757 }
1758
1759 fn declare_import(
1760 &mut self,
1761 module_name: &str,
1762 name: &str,
1763 params: &[WasmType],
1764 results: &[WasmType],
1765 ) -> String {
1766 let mut args = String::default();
1767 for (n, param) in params.iter().enumerate() {
1768 args.push_str(wit_bindgen_c::wasm_type(*param));
1769 if n + 1 != params.len() {
1770 args.push_str(", ");
1771 }
1772 }
1773 let result = if results.is_empty() {
1774 "void"
1775 } else {
1776 wit_bindgen_c::wasm_type(results[0])
1777 };
1778 let variant = AbiVariant::GuestImport;
1779 let (name, code) = self.declare_import2(module_name, name, &args, result, variant);
1780 self.r#gen.extern_c_decls.push_str(&code);
1781 name
1782 }
1783
1784 fn docs(src: &mut Source, docs: &Docs) {
1785 if let Some(docs) = docs.contents.as_ref() {

Callers 2

generate_functionMethod · 0.45
emitMethod · 0.45

Calls 5

declare_import2Method · 0.80
wasm_typeFunction · 0.50
iterMethod · 0.45
push_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected