mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
feat(runtime-c-api) Finish to extract last pieces of code.
This commit is contained in:
parent
361ff81db7
commit
849af62911
@ -2,8 +2,6 @@ extern crate wasmer_runtime;
|
||||
extern crate wasmer_runtime_core;
|
||||
|
||||
use libc::{uint32_t, uint8_t};
|
||||
use wasmer_runtime::Value;
|
||||
use wasmer_runtime_core::types::Type;
|
||||
|
||||
pub mod error;
|
||||
pub mod export;
|
||||
@ -15,9 +13,6 @@ pub mod module;
|
||||
pub mod table;
|
||||
pub mod value;
|
||||
|
||||
use instance::wasmer_instance_t;
|
||||
use value::{wasmer_value, wasmer_value_t, wasmer_value_tag};
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[repr(C)]
|
||||
pub enum wasmer_result_t {
|
||||
@ -42,87 +37,3 @@ pub struct wasmer_byte_array {
|
||||
bytes: *const uint8_t,
|
||||
bytes_len: uint32_t,
|
||||
}
|
||||
|
||||
impl From<wasmer_value_t> for Value {
|
||||
fn from(v: wasmer_value_t) -> Self {
|
||||
unsafe {
|
||||
match v {
|
||||
wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_I32,
|
||||
value: wasmer_value { I32 },
|
||||
} => Value::I32(I32),
|
||||
wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_I64,
|
||||
value: wasmer_value { I64 },
|
||||
} => Value::I64(I64),
|
||||
wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_F32,
|
||||
value: wasmer_value { F32 },
|
||||
} => Value::F32(F32),
|
||||
wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_F64,
|
||||
value: wasmer_value { F64 },
|
||||
} => Value::F64(F64),
|
||||
_ => panic!("not implemented"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Value> for wasmer_value_t {
|
||||
fn from(val: Value) -> Self {
|
||||
match val {
|
||||
Value::I32(x) => wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_I32,
|
||||
value: wasmer_value { I32: x },
|
||||
},
|
||||
Value::I64(x) => wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_I64,
|
||||
value: wasmer_value { I64: x },
|
||||
},
|
||||
Value::F32(x) => wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_F32,
|
||||
value: wasmer_value { F32: x },
|
||||
},
|
||||
Value::F64(x) => wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_F64,
|
||||
value: wasmer_value { F64: x },
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Type> for wasmer_value_tag {
|
||||
fn from(ty: Type) -> Self {
|
||||
match ty {
|
||||
Type::I32 => wasmer_value_tag::WASM_I32,
|
||||
Type::I64 => wasmer_value_tag::WASM_I64,
|
||||
Type::F32 => wasmer_value_tag::WASM_F32,
|
||||
Type::F64 => wasmer_value_tag::WASM_F64,
|
||||
_ => panic!("not implemented"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<wasmer_value_tag> for Type {
|
||||
fn from(v: wasmer_value_tag) -> Self {
|
||||
match v {
|
||||
wasmer_value_tag::WASM_I32 => Type::I32,
|
||||
wasmer_value_tag::WASM_I64 => Type::I64,
|
||||
wasmer_value_tag::WASM_F32 => Type::F32,
|
||||
wasmer_value_tag::WASM_F64 => Type::F64,
|
||||
_ => panic!("not implemented"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&wasmer_runtime::wasm::Type> for wasmer_value_tag {
|
||||
fn from(ty: &Type) -> Self {
|
||||
match *ty {
|
||||
Type::I32 => wasmer_value_tag::WASM_I32,
|
||||
Type::I64 => wasmer_value_tag::WASM_I64,
|
||||
Type::F32 => wasmer_value_tag::WASM_F32,
|
||||
Type::F64 => wasmer_value_tag::WASM_F64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ use crate::{
|
||||
error::{update_last_error, CApiError},
|
||||
export::wasmer_import_export_kind,
|
||||
import::wasmer_import_t,
|
||||
wasmer_byte_array, wasmer_instance_t, wasmer_result_t,
|
||||
instance::wasmer_instance_t,
|
||||
wasmer_byte_array, wasmer_result_t,
|
||||
};
|
||||
use libc::{c_int, uint32_t, uint8_t};
|
||||
use std::{collections::HashMap, slice};
|
||||
|
@ -1,6 +1,8 @@
|
||||
//! Wasm values.
|
||||
|
||||
use libc::{int32_t, int64_t};
|
||||
use wasmer_runtime::Value;
|
||||
use wasmer_runtime_core::types::Type;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[repr(u32)]
|
||||
@ -27,3 +29,87 @@ pub struct wasmer_value_t {
|
||||
pub tag: wasmer_value_tag,
|
||||
pub value: wasmer_value,
|
||||
}
|
||||
|
||||
impl From<wasmer_value_t> for Value {
|
||||
fn from(v: wasmer_value_t) -> Self {
|
||||
unsafe {
|
||||
match v {
|
||||
wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_I32,
|
||||
value: wasmer_value { I32 },
|
||||
} => Value::I32(I32),
|
||||
wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_I64,
|
||||
value: wasmer_value { I64 },
|
||||
} => Value::I64(I64),
|
||||
wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_F32,
|
||||
value: wasmer_value { F32 },
|
||||
} => Value::F32(F32),
|
||||
wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_F64,
|
||||
value: wasmer_value { F64 },
|
||||
} => Value::F64(F64),
|
||||
_ => panic!("not implemented"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Value> for wasmer_value_t {
|
||||
fn from(val: Value) -> Self {
|
||||
match val {
|
||||
Value::I32(x) => wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_I32,
|
||||
value: wasmer_value { I32: x },
|
||||
},
|
||||
Value::I64(x) => wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_I64,
|
||||
value: wasmer_value { I64: x },
|
||||
},
|
||||
Value::F32(x) => wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_F32,
|
||||
value: wasmer_value { F32: x },
|
||||
},
|
||||
Value::F64(x) => wasmer_value_t {
|
||||
tag: wasmer_value_tag::WASM_F64,
|
||||
value: wasmer_value { F64: x },
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Type> for wasmer_value_tag {
|
||||
fn from(ty: Type) -> Self {
|
||||
match ty {
|
||||
Type::I32 => wasmer_value_tag::WASM_I32,
|
||||
Type::I64 => wasmer_value_tag::WASM_I64,
|
||||
Type::F32 => wasmer_value_tag::WASM_F32,
|
||||
Type::F64 => wasmer_value_tag::WASM_F64,
|
||||
_ => panic!("not implemented"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<wasmer_value_tag> for Type {
|
||||
fn from(v: wasmer_value_tag) -> Self {
|
||||
match v {
|
||||
wasmer_value_tag::WASM_I32 => Type::I32,
|
||||
wasmer_value_tag::WASM_I64 => Type::I64,
|
||||
wasmer_value_tag::WASM_F32 => Type::F32,
|
||||
wasmer_value_tag::WASM_F64 => Type::F64,
|
||||
_ => panic!("not implemented"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&wasmer_runtime::wasm::Type> for wasmer_value_tag {
|
||||
fn from(ty: &Type) -> Self {
|
||||
match *ty {
|
||||
Type::I32 => wasmer_value_tag::WASM_I32,
|
||||
Type::I64 => wasmer_value_tag::WASM_I64,
|
||||
Type::F32 => wasmer_value_tag::WASM_F32,
|
||||
Type::F64 => wasmer_value_tag::WASM_F64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user