feat(api,emscritpen,wasi) Update WasmExternType to FromToNativeWasmType.

This commit is contained in:
Ivan Enderlin
2020-06-30 12:10:27 +02:00
parent 12c04fbd94
commit 3f924dbb45
7 changed files with 14 additions and 14 deletions

View File

@@ -3,7 +3,7 @@ mod global;
mod memory;
mod table;
pub use self::function::{Function, HostFunction, WasmExternType, WasmTypeList};
pub use self::function::{FromToNativeWasmType, Function, HostFunction, WasmTypeList};
pub use self::global::Global;
pub use self::memory::Memory;
pub use self::table::Table;

View File

@@ -19,7 +19,7 @@ mod utils;
pub use crate::exports::{ExportError, Exportable, Exports};
pub use crate::externals::{
Extern, Function, Global, HostFunction, Memory, Table, WasmExternType, WasmTypeList,
Extern, FromToNativeWasmType, Function, Global, HostFunction, Memory, Table, WasmTypeList,
};
pub use crate::import_object::{ImportObject, ImportObjectIterator, LikeNamespace};
pub use crate::instance::Instance;

View File

@@ -13,7 +13,7 @@ use crate::externals::function::{
FunctionDefinition, HostFunctionDefinition, VMDynamicFunction, VMDynamicFunctionWithEnv,
VMDynamicFunctionWithoutEnv, WasmFunctionDefinition,
};
use crate::{Function, FunctionType, RuntimeError, Store, WasmExternType, WasmTypeList};
use crate::{FromToNativeWasmType, Function, FunctionType, RuntimeError, Store, WasmTypeList};
use std::panic::{catch_unwind, AssertUnwindSafe};
use wasm_common::NativeWasmType;
use wasmer_runtime::{
@@ -97,7 +97,7 @@ macro_rules! impl_native_traits {
#[allow(unused_parens, non_snake_case)]
impl<'a $( , $x )*, Rets> NativeFunc<'a, ( $( $x ),* ), Rets>
where
$( $x: WasmExternType, )*
$( $x: FromToNativeWasmType, )*
Rets: WasmTypeList,
{
/// Call the typed func and return results.

View File

@@ -6,7 +6,7 @@
//! Therefore, you should use this abstraction whenever possible to avoid memory
//! related bugs when implementing an ABI.
use crate::{externals::Memory, WasmExternType};
use crate::{externals::Memory, FromToNativeWasmType};
use std::{cell::Cell, fmt, marker::PhantomData, mem};
use wasm_common::ValueType;
@@ -218,7 +218,7 @@ impl<T: Copy + ValueType> WasmPtr<T, Array> {
}
}
unsafe impl<T: Copy, Ty> WasmExternType for WasmPtr<T, Ty> {
unsafe impl<T: Copy, Ty> FromToNativeWasmType for WasmPtr<T, Ty> {
type Native = i32;
fn to_native(self) -> Self::Native {

View File

@@ -6,7 +6,7 @@
#![allow(dead_code)]
use std::{cell::Cell, fmt};
pub use wasmer::{Array, Memory, ValueType, WasmExternType};
pub use wasmer::{Array, FromToNativeWasmType, Memory, ValueType};
#[repr(transparent)]
pub struct WasmPtr<T: Copy, Ty = wasmer::Item>(wasmer::WasmPtr<T, Ty>);
@@ -26,8 +26,8 @@ impl<T: Copy, Ty> fmt::Debug for WasmPtr<T, Ty> {
}
}
unsafe impl<T: Copy, Ty> WasmExternType for WasmPtr<T, Ty> {
type Native = <wasmer::WasmPtr<T, Ty> as WasmExternType>::Native;
unsafe impl<T: Copy, Ty> FromToNativeWasmType for WasmPtr<T, Ty> {
type Native = <wasmer::WasmPtr<T, Ty> as FromToNativeWasmType>::Native;
fn to_native(self) -> Self::Native {
self.0.to_native()

View File

@@ -1,6 +1,6 @@
use crate::EmEnv;
use std::mem;
use wasmer::WasmExternType;
use wasmer::FromToNativeWasmType;
// use std::ffi::CStr;
use std::os::raw::c_char;
@@ -26,7 +26,7 @@ impl VarArgs {
}
}
unsafe impl WasmExternType for VarArgs {
unsafe impl FromToNativeWasmType for VarArgs {
type Native = i32;
fn to_native(self) -> Self::Native {

View File

@@ -3,7 +3,7 @@
use crate::syscalls::types::{__wasi_errno_t, __WASI_EFAULT};
use std::{cell::Cell, fmt};
pub use wasmer::{Array, Item, Memory, ValueType, WasmExternType, WasmPtr as BaseWasmPtr};
pub use wasmer::{Array, FromToNativeWasmType, Item, Memory, ValueType, WasmPtr as BaseWasmPtr};
#[repr(transparent)]
pub struct WasmPtr<T: Copy, Ty = Item>(BaseWasmPtr<T, Ty>);
@@ -24,8 +24,8 @@ impl<T: Copy, Ty> fmt::Debug for WasmPtr<T, Ty> {
}
}
unsafe impl<T: Copy, Ty> WasmExternType for WasmPtr<T, Ty> {
type Native = <BaseWasmPtr<T, Ty> as WasmExternType>::Native;
unsafe impl<T: Copy, Ty> FromToNativeWasmType for WasmPtr<T, Ty> {
type Native = <BaseWasmPtr<T, Ty> as FromToNativeWasmType>::Native;
fn to_native(self) -> Self::Native {
self.0.to_native()