MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / wrap_func

Function wrap_func

tests/all/host_funcs.rs:6–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5#[test]
6fn wrap_func() -> Result<()> {
7 let engine = Engine::default();
8 let mut linker = Linker::<()>::new(&engine);
9 linker.allow_shadowing(true);
10
11 linker.func_wrap("", "", || {})?;
12 linker.func_wrap("m", "f", |_: i32| {})?;
13 linker.func_wrap("m", "f2", |_: i32, _: i64| {})?;
14 linker.func_wrap("m2", "f", |_: f32, _: f64| {})?;
15 linker.func_wrap("m2", "f2", || -> i32 { 0 })?;
16 linker.func_wrap("", "", || -> i64 { 0 })?;
17 linker.func_wrap("m", "f", || -> f32 { 0.0 })?;
18 linker.func_wrap("m2", "f", || -> f64 { 0.0 })?;
19 linker.func_wrap("m3", "", || -> Option<Rooted<ExternRef>> { None })?;
20 linker.func_wrap("m3", "f", || -> Option<Func> { None })?;
21
22 linker.func_wrap("", "f1", || -> Result<()> {
23 loop {}
24 })?;
25 linker.func_wrap("", "f2", || -> Result<i32> {
26 loop {}
27 })?;
28 linker.func_wrap("", "f3", || -> Result<i64> {
29 loop {}
30 })?;
31 linker.func_wrap("", "f4", || -> Result<f32> {
32 loop {}
33 })?;
34 linker.func_wrap("", "f5", || -> Result<f64> {
35 loop {}
36 })?;
37 linker.func_wrap("", "f6", || -> Result<Option<Rooted<ExternRef>>> {
38 loop {}
39 })?;
40 linker.func_wrap("", "f7", || -> Result<Option<Func>> {
41 loop {}
42 })?;
43 Ok(())
44}
45
46#[test]
47fn drop_func() -> Result<()> {

Callers

nothing calls this directly

Calls 4

OkFunction · 0.85
newFunction · 0.50
allow_shadowingMethod · 0.45
func_wrapMethod · 0.45

Tested by

no test coverage detected