MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / register_native_module

Function register_native_module

compiler/src/main/exports.rs:58–68  ·  view source on GitHub ↗
(spec_ptr: *const u8, spec_len: u32, names_ptr: *const u8, names_len: u32, base_id: u32)

Source from the content-addressed store, hash-verified

56
57#[unsafe(no_mangle)]
58pub 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)]
71pub unsafe extern "C" fn reset_modules() {

Callers

nothing calls this directly

Calls 6

safe_str_ownedFunction · 0.85
safe_bytesFunction · 0.85
with_runtimeFunction · 0.85
collectMethod · 0.80
pushMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected