Phase 12: add wasm_v2 scaffold (unified vtable slots), expand host by-slot (Map/String), STRICT extern diagnostics, identical-exec console.log test, and CLAUDE_WASM_TASK handoff
This commit is contained in:
@ -91,6 +91,45 @@ fn main() {
|
||||
} else {
|
||||
println!(" get(slot=100) failed with code {}", code2);
|
||||
}
|
||||
|
||||
// MapBox slots test: set/get/has/size
|
||||
println!("\nReverse host-call (by-slot) MapBox test:");
|
||||
let map = nyash_rust::boxes::map_box::MapBox::new();
|
||||
let map_h = nyash_rust::runtime::host_handles::to_handle_box(Box::new(map));
|
||||
// set("k","v") → slot=204
|
||||
let mut tlv_set = nyash_rust::runtime::plugin_ffi_common::encode_tlv_header(2);
|
||||
nyash_rust::runtime::plugin_ffi_common::encode::string(&mut tlv_set, "k");
|
||||
nyash_rust::runtime::plugin_ffi_common::encode::string(&mut tlv_set, "v");
|
||||
let mut out_s = vec![0u8; 256];
|
||||
let mut out_s_len: usize = out_s.len();
|
||||
let code_s = unsafe { nyash_rust::runtime::host_api::nyrt_host_call_slot(map_h, 204, tlv_set.as_ptr(), tlv_set.len(), out_s.as_mut_ptr(), &mut out_s_len) };
|
||||
println!(" set(slot=204) -> code={}, out_len={}", code_s, out_s_len);
|
||||
// get("k") → slot=203
|
||||
let mut tlv_get = nyash_rust::runtime::plugin_ffi_common::encode_tlv_header(1);
|
||||
nyash_rust::runtime::plugin_ffi_common::encode::string(&mut tlv_get, "k");
|
||||
let mut out_g = vec![0u8; 256];
|
||||
let mut out_g_len: usize = out_g.len();
|
||||
let code_g = unsafe { nyash_rust::runtime::host_api::nyrt_host_call_slot(map_h, 203, tlv_get.as_ptr(), tlv_get.len(), out_g.as_mut_ptr(), &mut out_g_len) };
|
||||
if code_g == 0 {
|
||||
if let Some((tag, _sz, payload)) = nyash_rust::runtime::plugin_ffi_common::decode::tlv_first(&out_g[..out_g_len]) {
|
||||
if tag == 6 || tag == 7 {
|
||||
let s = nyash_rust::runtime::plugin_ffi_common::decode::string(payload);
|
||||
println!(" get(slot=203) -> '{}'", s);
|
||||
} else {
|
||||
println!(" get(slot=203) -> tag={}, size={}", tag, _sz);
|
||||
}
|
||||
}
|
||||
}
|
||||
// has("k") → slot=202
|
||||
let mut out_hb = vec![0u8; 16];
|
||||
let mut out_hb_len: usize = out_hb.len();
|
||||
let code_hb = unsafe { nyash_rust::runtime::host_api::nyrt_host_call_slot(map_h, 202, tlv_get.as_ptr(), tlv_get.len(), out_hb.as_mut_ptr(), &mut out_hb_len) };
|
||||
println!(" has(slot=202) -> code={}, out_len={}", code_hb, out_hb_len);
|
||||
// size() → slot=200
|
||||
let mut out_sz = vec![0u8; 32];
|
||||
let mut out_sz_len: usize = out_sz.len();
|
||||
let code_sz = unsafe { nyash_rust::runtime::host_api::nyrt_host_call_slot(map_h, 200, std::ptr::null(), 0, out_sz.as_mut_ptr(), &mut out_sz_len) };
|
||||
println!(" size(slot=200) -> code={}, out_len={}", code_sz, out_sz_len);
|
||||
|
||||
println!("\nTest completed!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user