MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / perry_str

Function perry_str

native/watchos/src/lib.rs:40–50  ·  view source on GitHub ↗

Decode a Perry-side string pointer (i64 on this ABI) into a borrowed &str. Returns "" for null / too-small pointers to keep the FFI boundary robust.

(ptr: i64)

Source from the content-addressed store, hash-verified

38/// Decode a Perry-side string pointer (i64 on this ABI) into a borrowed &str.
39/// Returns "" for null / too-small pointers to keep the FFI boundary robust.
40fn perry_str<'a>(ptr: i64) -> &'a str {
41 if ptr == 0 { return ""; }
42 let p = ptr as *const u8;
43 if (p as usize) < 0x1000 { return ""; }
44 unsafe {
45 let header = p as *const StringHeader;
46 let len = (*header).byte_len as usize;
47 let data = p.add(std::mem::size_of::<StringHeader>());
48 std::str::from_utf8_unchecked(std::slice::from_raw_parts(data, len))
49 }
50}
51
52/// Allocate a Perry-side heap string (StringHeader + UTF-8 payload) and return
53/// its pointer as the i64 the FFI boundary expects. Mirrors `perry_str`'s

Callers 9

bloom_load_textureFunction · 0.85
bloom_draw_textFunction · 0.85
bloom_draw_text_exFunction · 0.85
bloom_measure_textFunction · 0.85
bloom_file_existsFunction · 0.85
bloom_read_fileFunction · 0.85
bloom_load_soundFunction · 0.85
bloom_load_musicFunction · 0.85
bloom_load_modelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected