From 3f924dbb45677b83f01e20240346912bfdb99f9c Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 30 Jun 2020 12:10:27 +0200 Subject: [PATCH] feat(api,emscritpen,wasi) Update `WasmExternType` to `FromToNativeWasmType`. --- lib/api/src/externals/mod.rs | 2 +- lib/api/src/lib.rs | 2 +- lib/api/src/native.rs | 4 ++-- lib/api/src/ptr.rs | 4 ++-- lib/emscripten/src/ptr.rs | 6 +++--- lib/emscripten/src/varargs.rs | 4 ++-- lib/wasi/src/ptr.rs | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/api/src/externals/mod.rs b/lib/api/src/externals/mod.rs index 368d3134c..8ea9fe3b4 100644 --- a/lib/api/src/externals/mod.rs +++ b/lib/api/src/externals/mod.rs @@ -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; diff --git a/lib/api/src/lib.rs b/lib/api/src/lib.rs index d6c6998d8..85ab180f8 100644 --- a/lib/api/src/lib.rs +++ b/lib/api/src/lib.rs @@ -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; diff --git a/lib/api/src/native.rs b/lib/api/src/native.rs index cc89da9af..09616b409 100644 --- a/lib/api/src/native.rs +++ b/lib/api/src/native.rs @@ -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. diff --git a/lib/api/src/ptr.rs b/lib/api/src/ptr.rs index 4d181e217..52ee823f9 100644 --- a/lib/api/src/ptr.rs +++ b/lib/api/src/ptr.rs @@ -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 WasmPtr { } } -unsafe impl WasmExternType for WasmPtr { +unsafe impl FromToNativeWasmType for WasmPtr { type Native = i32; fn to_native(self) -> Self::Native { diff --git a/lib/emscripten/src/ptr.rs b/lib/emscripten/src/ptr.rs index 727b3541c..54d5fada6 100644 --- a/lib/emscripten/src/ptr.rs +++ b/lib/emscripten/src/ptr.rs @@ -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(wasmer::WasmPtr); @@ -26,8 +26,8 @@ impl fmt::Debug for WasmPtr { } } -unsafe impl WasmExternType for WasmPtr { - type Native = as WasmExternType>::Native; +unsafe impl FromToNativeWasmType for WasmPtr { + type Native = as FromToNativeWasmType>::Native; fn to_native(self) -> Self::Native { self.0.to_native() diff --git a/lib/emscripten/src/varargs.rs b/lib/emscripten/src/varargs.rs index 72f9f16ad..09344fed2 100644 --- a/lib/emscripten/src/varargs.rs +++ b/lib/emscripten/src/varargs.rs @@ -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 { diff --git a/lib/wasi/src/ptr.rs b/lib/wasi/src/ptr.rs index 86780bb98..a4c76e3e3 100644 --- a/lib/wasi/src/ptr.rs +++ b/lib/wasi/src/ptr.rs @@ -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(BaseWasmPtr); @@ -24,8 +24,8 @@ impl fmt::Debug for WasmPtr { } } -unsafe impl WasmExternType for WasmPtr { - type Native = as WasmExternType>::Native; +unsafe impl FromToNativeWasmType for WasmPtr { + type Native = as FromToNativeWasmType>::Native; fn to_native(self) -> Self::Native { self.0.to_native()