MCPcopy Index your code
hub / github.com/RustPython/RustPython / print

Function print

example_projects/wasm32_without_js/wasm-runtime/src/main.rs:75–85  ·  view source on GitHub ↗

p and l are the message pointer and length in wasm memory.

(mut ctx: FunctionEnvMut<Ctx>, p: i32, l: i32)

Source from the content-addressed store, hash-verified

73
74// p and l are the message pointer and length in wasm memory.
75fn print(mut ctx: FunctionEnvMut<Ctx>, p: i32, l: i32) -> i32 {
76 let (c, s) = ctx.data_and_store_mut();
77 let mut msg = vec![0u8; l as usize];
78 let m = c.mem.as_ref().unwrap().view(&s);
79 if m.read(p as u64, &mut msg).is_err() {
80 return -1;
81 }
82 let s = std::str::from_utf8(&msg).expect("print got non-utf8 str");
83 println!("{s}");
84 0
85}
86
87fn main() {
88 let mut store = Store::default();

Callers 15

evalFunction · 0.50
test_basic_managerFunction · 0.50
child_fnFunction · 0.50
jsontests.pyFile · 0.50
sandbox_smoke.pyFile · 0.50
stdlib_ast.pyFile · 0.50

Calls 4

is_errMethod · 0.80
unwrapMethod · 0.45
as_refMethod · 0.45
readMethod · 0.45

Tested by 8

test_basic_managerFunction · 0.40
child_fnFunction · 0.40
_assert_printFunction · 0.40
skip_if_unsupportedFunction · 0.40
test_all_slicesFunction · 0.40