(spec_ptr: *const u8, spec_len: u32, names_ptr: *const u8, names_len: u32, base_id: u32)
| 56 | |
| 57 | #[unsafe(no_mangle)] |
| 58 | pub unsafe extern "C" fn register_native_module(spec_ptr: *const u8, spec_len: u32, names_ptr: *const u8, names_len: u32, base_id: u32) { |
| 59 | use alloc::vec::Vec; |
| 60 | let spec = unsafe { safe_str_owned(spec_ptr, spec_len) }; |
| 61 | let names_str = core::str::from_utf8(unsafe { safe_bytes(names_ptr, names_len) }).unwrap_or(""); |
| 62 | let funcs: Vec<(String, u32)> = names_str.split('\n') |
| 63 | .filter(|n| !n.is_empty()) |
| 64 | .enumerate() |
| 65 | .map(|(i, name)| (name.to_string(), base_id + i as u32)) |
| 66 | .collect(); |
| 67 | with_runtime(|rt| rt.registry.push((spec, ModuleEntry::Native(funcs)))); |
| 68 | } |
| 69 | |
| 70 | #[unsafe(no_mangle)] |
| 71 | pub unsafe extern "C" fn reset_modules() { |
nothing calls this directly
no test coverage detected