Get multi.c working in the Wasm C API

This commit is contained in:
Mark McCaskey
2020-12-17 14:35:55 -08:00
parent 8e343633df
commit 62663ab5e1
11 changed files with 146 additions and 22 deletions

View File

@@ -77,6 +77,39 @@ pub struct wasm_val_t {
pub of: wasm_val_inner,
}
impl std::fmt::Debug for wasm_val_t {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let mut ds = f.debug_struct("wasm_val_t");
ds.field("kind", &self.kind);
match self.kind.try_into() {
Ok(wasm_valkind_enum::WASM_I32) => {
ds.field("i32", &unsafe { self.of.int32_t });
}
Ok(wasm_valkind_enum::WASM_I64) => {
ds.field("i64", &unsafe { self.of.int64_t });
}
Ok(wasm_valkind_enum::WASM_F32) => {
ds.field("f32", &unsafe { self.of.float32_t });
}
Ok(wasm_valkind_enum::WASM_F64) => {
ds.field("f64", &unsafe { self.of.float64_t });
}
Ok(wasm_valkind_enum::WASM_ANYREF) => {
ds.field("anyref", &unsafe { self.of.wref });
}
Ok(wasm_valkind_enum::WASM_FUNCREF) => {
ds.field("funcref", &unsafe { self.of.wref });
}
Err(_) => {
ds.field("value", &"Invalid value type");
}
}
ds.finish()
}
}
wasm_declare_vec!(val);
impl Clone for wasm_val_t {