mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-12 05:18:43 +00:00
Moved reexports one level down
This commit is contained in:
@@ -3,13 +3,13 @@
|
|||||||
// use crate::js::RuntimeError;
|
// use crate::js::RuntimeError;
|
||||||
use crate::imports::Imports;
|
use crate::imports::Imports;
|
||||||
use crate::js::externals::{Extern, Function, Global, Memory, Table};
|
use crate::js::externals::{Extern, Function, Global, Memory, Table};
|
||||||
|
use crate::js::instance::Instance;
|
||||||
use crate::js::vm::{VMExtern, VMFunction, VMGlobal, VMMemory, VMTable};
|
use crate::js::vm::{VMExtern, VMFunction, VMGlobal, VMMemory, VMTable};
|
||||||
use crate::js::wasm_bindgen_polyfill::Global as JsGlobal;
|
use crate::js::wasm_bindgen_polyfill::Global as JsGlobal;
|
||||||
use crate::js::Instance;
|
|
||||||
use crate::store::{AsStoreMut, AsStoreRef};
|
use crate::store::{AsStoreMut, AsStoreRef};
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use crate::Exports;
|
use crate::Exports;
|
||||||
use crate::ValType;
|
use crate::Type;
|
||||||
use js_sys::Function as JsFunction;
|
use js_sys::Function as JsFunction;
|
||||||
use js_sys::WebAssembly::{Memory as JsMemory, Table as JsTable};
|
use js_sys::WebAssembly::{Memory as JsMemory, Table as JsTable};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@@ -32,12 +32,12 @@ pub trait AsJs: Sized {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn param_from_js(ty: &ValType, js_val: &JsValue) -> Value {
|
pub fn param_from_js(ty: &Type, js_val: &JsValue) -> Value {
|
||||||
match ty {
|
match ty {
|
||||||
ValType::I32 => Value::I32(js_val.as_f64().unwrap() as _),
|
Type::I32 => Value::I32(js_val.as_f64().unwrap() as _),
|
||||||
ValType::I64 => Value::I64(js_val.as_f64().unwrap() as _),
|
Type::I64 => Value::I64(js_val.as_f64().unwrap() as _),
|
||||||
ValType::F32 => Value::F32(js_val.as_f64().unwrap() as _),
|
Type::F32 => Value::F32(js_val.as_f64().unwrap() as _),
|
||||||
ValType::F64 => Value::F64(js_val.as_f64().unwrap()),
|
Type::F64 => Value::F64(js_val.as_f64().unwrap()),
|
||||||
t => unimplemented!(
|
t => unimplemented!(
|
||||||
"The type `{:?}` is not yet supported in the JS Function API",
|
"The type `{:?}` is not yet supported in the JS Function API",
|
||||||
t
|
t
|
||||||
@@ -46,7 +46,7 @@ pub fn param_from_js(ty: &ValType, js_val: &JsValue) -> Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AsJs for Value {
|
impl AsJs for Value {
|
||||||
type DefinitionType = ValType;
|
type DefinitionType = Type;
|
||||||
|
|
||||||
fn as_jsvalue(&self, _store: &impl AsStoreRef) -> JsValue {
|
fn as_jsvalue(&self, _store: &impl AsStoreRef) -> JsValue {
|
||||||
match self {
|
match self {
|
||||||
@@ -71,7 +71,7 @@ impl AsJs for Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AsJs for wasmer_types::RawValue {
|
impl AsJs for wasmer_types::RawValue {
|
||||||
type DefinitionType = ValType;
|
type DefinitionType = Type;
|
||||||
|
|
||||||
fn as_jsvalue(&self, _store: &impl AsStoreRef) -> JsValue {
|
fn as_jsvalue(&self, _store: &impl AsStoreRef) -> JsValue {
|
||||||
unsafe { JsValue::from_f64(self.into()) }
|
unsafe { JsValue::from_f64(self.into()) }
|
||||||
|
|||||||
2
lib/api/src/js/externals/function.rs
vendored
2
lib/api/src/js/externals/function.rs
vendored
@@ -4,10 +4,10 @@ use crate::function_env::{FunctionEnv, FunctionEnvMut};
|
|||||||
use crate::js::as_js::{param_from_js, AsJs}; /* ValFuncRef */
|
use crate::js::as_js::{param_from_js, AsJs}; /* ValFuncRef */
|
||||||
use crate::js::externals::Extern;
|
use crate::js::externals::Extern;
|
||||||
use crate::js::vm::VMExtern;
|
use crate::js::vm::VMExtern;
|
||||||
use crate::js::FunctionType;
|
|
||||||
use crate::js::RuntimeError;
|
use crate::js::RuntimeError;
|
||||||
use crate::store::{AsStoreMut, AsStoreRef, StoreMut};
|
use crate::store::{AsStoreMut, AsStoreRef, StoreMut};
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
|
use crate::FunctionType;
|
||||||
use crate::TypedFunction;
|
use crate::TypedFunction;
|
||||||
use js_sys::{Array, Function as JSFunction};
|
use js_sys::{Array, Function as JSFunction};
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
|||||||
4
lib/api/src/js/externals/global.rs
vendored
4
lib/api/src/js/externals/global.rs
vendored
@@ -2,11 +2,11 @@ use crate::exports::{ExportError, Exportable};
|
|||||||
use crate::js::externals::Extern;
|
use crate::js::externals::Extern;
|
||||||
use crate::js::vm::{VMExtern, VMGlobal};
|
use crate::js::vm::{VMExtern, VMGlobal};
|
||||||
use crate::js::wasm_bindgen_polyfill::Global as JSGlobal;
|
use crate::js::wasm_bindgen_polyfill::Global as JSGlobal;
|
||||||
use crate::js::GlobalType;
|
|
||||||
use crate::js::Mutability;
|
|
||||||
use crate::js::RuntimeError;
|
use crate::js::RuntimeError;
|
||||||
use crate::store::{AsStoreMut, AsStoreRef};
|
use crate::store::{AsStoreMut, AsStoreRef};
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
|
use crate::GlobalType;
|
||||||
|
use crate::Mutability;
|
||||||
use wasm_bindgen::JsValue;
|
use wasm_bindgen::JsValue;
|
||||||
use wasmer_types::{RawValue, Type};
|
use wasmer_types::{RawValue, Type};
|
||||||
|
|
||||||
|
|||||||
2
lib/api/src/js/externals/memory.rs
vendored
2
lib/api/src/js/externals/memory.rs
vendored
@@ -1,9 +1,9 @@
|
|||||||
use crate::exports::{ExportError, Exportable};
|
use crate::exports::{ExportError, Exportable};
|
||||||
use crate::js::externals::Extern;
|
use crate::js::externals::Extern;
|
||||||
use crate::js::vm::{VMExtern, VMMemory};
|
use crate::js::vm::{VMExtern, VMMemory};
|
||||||
use crate::js::MemoryType;
|
|
||||||
use crate::mem_access::MemoryAccessError;
|
use crate::mem_access::MemoryAccessError;
|
||||||
use crate::store::{AsStoreMut, AsStoreRef, StoreObjects};
|
use crate::store::{AsStoreMut, AsStoreRef, StoreObjects};
|
||||||
|
use crate::MemoryType;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|||||||
2
lib/api/src/js/externals/table.rs
vendored
2
lib/api/src/js/externals/table.rs
vendored
@@ -2,9 +2,9 @@ use crate::exports::{ExportError, Exportable};
|
|||||||
use crate::js::externals::Extern;
|
use crate::js::externals::Extern;
|
||||||
use crate::js::vm::{VMExtern, VMFunction, VMTable};
|
use crate::js::vm::{VMExtern, VMFunction, VMTable};
|
||||||
use crate::js::RuntimeError;
|
use crate::js::RuntimeError;
|
||||||
use crate::js::{FunctionType, TableType};
|
|
||||||
use crate::store::{AsStoreMut, AsStoreRef};
|
use crate::store::{AsStoreMut, AsStoreRef};
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
|
use crate::{FunctionType, TableType};
|
||||||
use js_sys::Function;
|
use js_sys::Function;
|
||||||
|
|
||||||
/// A WebAssembly `table` instance.
|
/// A WebAssembly `table` instance.
|
||||||
|
|||||||
@@ -39,33 +39,14 @@ pub(crate) mod vm;
|
|||||||
mod wasm_bindgen_polyfill;
|
mod wasm_bindgen_polyfill;
|
||||||
|
|
||||||
pub use crate::js::as_js::AsJs;
|
pub use crate::js::as_js::AsJs;
|
||||||
pub use crate::js::engine::Engine;
|
|
||||||
pub use crate::js::error::{DeserializeError, LinkError, SerializeError};
|
pub use crate::js::error::{DeserializeError, LinkError, SerializeError};
|
||||||
pub use crate::js::externals::{
|
pub use crate::js::externals::{
|
||||||
Extern, FromToNativeWasmType, Function, Global, HostFunction, Memory, MemoryError, MemoryView,
|
Extern, FromToNativeWasmType, Function, Global, HostFunction, Memory, MemoryError, MemoryView,
|
||||||
Table, WasmTypeList,
|
Table, WasmTypeList,
|
||||||
};
|
};
|
||||||
pub use crate::js::instance::Instance;
|
|
||||||
pub use crate::js::module::{Module, ModuleTypeHints};
|
pub use crate::js::module::{Module, ModuleTypeHints};
|
||||||
pub use crate::js::store::StoreObjects;
|
pub use crate::js::store::StoreObjects;
|
||||||
pub use crate::js::trap::RuntimeError;
|
pub use crate::js::trap::RuntimeError;
|
||||||
|
|
||||||
pub use wasmer_types::is_wasm;
|
|
||||||
// TODO: OnCalledAction is needed for asyncify. It will be refactored with https://github.com/wasmerio/wasmer/issues/3451
|
|
||||||
pub use wasmer_types::{
|
|
||||||
Bytes, ExportIndex, GlobalInit, LocalFunctionIndex, OnCalledAction, Pages, ValueType,
|
|
||||||
WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE,
|
|
||||||
};
|
|
||||||
pub use wasmer_types::{
|
|
||||||
ExportType, ExternType, FunctionType, GlobalType, ImportType, MemoryType, Mutability,
|
|
||||||
TableType, Type as ValType, Type,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(feature = "wat")]
|
|
||||||
pub use wat::parse_bytes as wat2wasm;
|
|
||||||
|
|
||||||
#[cfg(feature = "wasm-types-polyfill")]
|
#[cfg(feature = "wasm-types-polyfill")]
|
||||||
pub use wasmparser;
|
pub use wasmparser;
|
||||||
|
|
||||||
/// Version number of this crate.
|
|
||||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
||||||
|
|||||||
@@ -475,9 +475,28 @@ pub use store::{TrapHandlerFn, Tunables};
|
|||||||
pub use typed_function::TypedFunction;
|
pub use typed_function::TypedFunction;
|
||||||
pub use value::Value;
|
pub use value::Value;
|
||||||
|
|
||||||
|
// Reexport from other modules
|
||||||
|
|
||||||
|
pub use wasmer_derive::ValueType;
|
||||||
|
// TODO: OnCalledAction is needed for asyncify. It will be refactored with https://github.com/wasmerio/wasmer/issues/3451
|
||||||
|
pub use wasmer_types::{
|
||||||
|
is_wasm, Bytes, CompileError, CpuFeature, DeserializeError, ExportIndex, ExportType,
|
||||||
|
ExternType, FunctionType, GlobalInit, GlobalType, ImportType, LocalFunctionIndex, MemoryType,
|
||||||
|
MiddlewareError, Mutability, OnCalledAction, Pages, ParseCpuFeatureError, SerializeError,
|
||||||
|
TableType, Target, Type, ValueType, WasmError, WasmResult, WASM_MAX_PAGES, WASM_MIN_PAGES,
|
||||||
|
WASM_PAGE_SIZE,
|
||||||
|
};
|
||||||
|
#[cfg(feature = "wat")]
|
||||||
|
pub use wat::parse_bytes as wat2wasm;
|
||||||
|
|
||||||
|
// Deprecated types
|
||||||
|
|
||||||
/// This type is deprecated, it has been replaced by TypedFunction.
|
/// This type is deprecated, it has been replaced by TypedFunction.
|
||||||
#[deprecated(
|
#[deprecated(
|
||||||
since = "3.0.0",
|
since = "3.0.0",
|
||||||
note = "NativeFunc has been replaced by TypedFunction"
|
note = "NativeFunc has been replaced by TypedFunction"
|
||||||
)]
|
)]
|
||||||
pub type NativeFunc<Args = (), Rets = ()> = TypedFunction<Args, Rets>;
|
pub type NativeFunc<Args = (), Rets = ()> = TypedFunction<Args, Rets>;
|
||||||
|
|
||||||
|
/// Version number of this crate.
|
||||||
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|||||||
4
lib/api/src/sys/externals/global.rs
vendored
4
lib/api/src/sys/externals/global.rs
vendored
@@ -1,10 +1,10 @@
|
|||||||
use crate::exports::{ExportError, Exportable};
|
use crate::exports::{ExportError, Exportable};
|
||||||
use crate::store::{AsStoreMut, AsStoreRef};
|
use crate::store::{AsStoreMut, AsStoreRef};
|
||||||
use crate::sys::externals::Extern;
|
use crate::sys::externals::Extern;
|
||||||
use crate::sys::GlobalType;
|
|
||||||
use crate::sys::Mutability;
|
|
||||||
use crate::sys::RuntimeError;
|
use crate::sys::RuntimeError;
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
|
use crate::GlobalType;
|
||||||
|
use crate::Mutability;
|
||||||
use wasmer_vm::{InternalStoreHandle, StoreHandle, VMExtern, VMGlobal};
|
use wasmer_vm::{InternalStoreHandle, StoreHandle, VMExtern, VMGlobal};
|
||||||
|
|
||||||
/// A WebAssembly `global` instance.
|
/// A WebAssembly `global` instance.
|
||||||
|
|||||||
2
lib/api/src/sys/externals/memory.rs
vendored
2
lib/api/src/sys/externals/memory.rs
vendored
@@ -1,8 +1,8 @@
|
|||||||
use crate::exports::{ExportError, Exportable};
|
use crate::exports::{ExportError, Exportable};
|
||||||
use crate::store::{AsStoreMut, AsStoreRef};
|
use crate::store::{AsStoreMut, AsStoreRef};
|
||||||
use crate::sys::externals::Extern;
|
use crate::sys::externals::Extern;
|
||||||
use crate::sys::MemoryType;
|
|
||||||
use crate::MemoryAccessError;
|
use crate::MemoryAccessError;
|
||||||
|
use crate::MemoryType;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|||||||
2
lib/api/src/sys/externals/mod.rs
vendored
2
lib/api/src/sys/externals/mod.rs
vendored
@@ -12,7 +12,7 @@ pub use self::memory_view::MemoryView;
|
|||||||
pub use self::table::Table;
|
pub use self::table::Table;
|
||||||
|
|
||||||
use crate::exports::{ExportError, Exportable};
|
use crate::exports::{ExportError, Exportable};
|
||||||
use crate::sys::ExternType;
|
use crate::ExternType;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use wasmer_vm::VMExtern;
|
use wasmer_vm::VMExtern;
|
||||||
|
|
||||||
|
|||||||
2
lib/api/src/sys/externals/table.rs
vendored
2
lib/api/src/sys/externals/table.rs
vendored
@@ -1,7 +1,7 @@
|
|||||||
use crate::exports::{ExportError, Exportable};
|
use crate::exports::{ExportError, Exportable};
|
||||||
use crate::store::{AsStoreMut, AsStoreRef};
|
use crate::store::{AsStoreMut, AsStoreRef};
|
||||||
use crate::sys::externals::Extern;
|
use crate::sys::externals::Extern;
|
||||||
use crate::sys::TableType;
|
use crate::TableType;
|
||||||
use crate::Value;
|
use crate::Value;
|
||||||
use crate::{sys::RuntimeError, ExternRef, Function};
|
use crate::{sys::RuntimeError, ExternRef, Function};
|
||||||
use wasmer_vm::{InternalStoreHandle, StoreHandle, TableElement, VMExtern, VMTable};
|
use wasmer_vm::{InternalStoreHandle, StoreHandle, TableElement, VMExtern, VMTable};
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ pub use crate::sys::externals::{
|
|||||||
Extern, FromToNativeWasmType, Function, Global, HostFunction, Memory, MemoryView, Table,
|
Extern, FromToNativeWasmType, Function, Global, HostFunction, Memory, MemoryView, Table,
|
||||||
WasmTypeList,
|
WasmTypeList,
|
||||||
};
|
};
|
||||||
pub use crate::sys::instance::Instance;
|
|
||||||
|
|
||||||
pub use crate::sys::tunables::BaseTunables;
|
pub use crate::sys::tunables::BaseTunables;
|
||||||
pub use target_lexicon::{Architecture, CallingConvention, OperatingSystem, Triple, HOST};
|
pub use target_lexicon::{Architecture, CallingConvention, OperatingSystem, Triple, HOST};
|
||||||
@@ -19,19 +18,6 @@ pub use wasmer_compiler::{
|
|||||||
wasmparser, CompilerConfig, FunctionMiddleware, MiddlewareReaderState, ModuleMiddleware,
|
wasmparser, CompilerConfig, FunctionMiddleware, MiddlewareReaderState, ModuleMiddleware,
|
||||||
};
|
};
|
||||||
pub use wasmer_compiler::{Features, FrameInfo, LinkError, RuntimeError, Tunables};
|
pub use wasmer_compiler::{Features, FrameInfo, LinkError, RuntimeError, Tunables};
|
||||||
pub use wasmer_derive::ValueType;
|
|
||||||
pub use wasmer_types::is_wasm;
|
|
||||||
// TODO: OnCalledAction is needed for asyncify. It will be refactored with https://github.com/wasmerio/wasmer/issues/3451
|
|
||||||
pub use wasmer_types::{
|
|
||||||
CpuFeature, ExportType, ExternType, FunctionType, GlobalType, ImportType, MemoryType,
|
|
||||||
Mutability, OnCalledAction, TableType, Target, Type,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub use wasmer_types::{
|
|
||||||
Bytes, CompileError, DeserializeError, ExportIndex, GlobalInit, LocalFunctionIndex,
|
|
||||||
MiddlewareError, Pages, ParseCpuFeatureError, SerializeError, ValueType, WasmError, WasmResult,
|
|
||||||
WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE,
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: should those be moved into wasmer::vm as well?
|
// TODO: should those be moved into wasmer::vm as well?
|
||||||
pub use wasmer_vm::{raise_user_trap, MemoryError};
|
pub use wasmer_vm::{raise_user_trap, MemoryError};
|
||||||
@@ -58,6 +44,3 @@ pub use wasmer_compiler_llvm::{LLVMOptLevel, LLVM};
|
|||||||
|
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
pub use wasmer_compiler::{Artifact, EngineBuilder};
|
pub use wasmer_compiler::{Artifact, EngineBuilder};
|
||||||
|
|
||||||
/// Version number of this crate.
|
|
||||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
||||||
|
|||||||
Reference in New Issue
Block a user