(ptr: *const u8, len: u32)
| 241 | |
| 242 | #[unsafe(no_mangle)] |
| 243 | pub unsafe extern "C" fn run_push_event(ptr: *const u8, len: u32) -> i32 { |
| 244 | let bytes = unsafe { safe_bytes(ptr, len) }; |
| 245 | let s = match core::str::from_utf8(bytes) { |
| 246 | Ok(s) => s.to_string(), |
| 247 | Err(_) => return 1, |
| 248 | }; |
| 249 | with_runtime(|rt| { |
| 250 | let Some(paused) = rt.paused_run.as_mut() else { return 1; }; |
| 251 | let Some(vm) = paused.vm.as_mut() else { return 1; }; |
| 252 | let val = match vm.heap.alloc(HeapObj::Str(s)) { |
| 253 | Ok(v) => v, |
| 254 | Err(_) => return 2, |
| 255 | }; |
| 256 | vm.inject_event(val); |
| 257 | 0 |
| 258 | }) |
| 259 | } |
| 260 | |
| 261 | /* `set_host_*` prologue: take `handle`'s Val (1 = stale) and run `f` on the paused VM (3 = no paused run). */ |
| 262 | fn with_paused_vm(handle: u32, f: impl FnOnce(&mut VM<'static>, crate::modules::vm::types::Val) -> i32) -> i32 { |
nothing calls this directly
no test coverage detected