mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 06:08:29 +00:00
Implement PartialEq for all externals
This commit is contained in:
4
lib/api/src/externals/function.rs
vendored
4
lib/api/src/externals/function.rs
vendored
@@ -81,7 +81,7 @@ mod private {
|
|||||||
/// with native functions. Attempting to create a native `Function` with one will
|
/// with native functions. Attempting to create a native `Function` with one will
|
||||||
/// result in a panic.
|
/// result in a panic.
|
||||||
/// [Closures as host functions tracking issue](https://github.com/wasmerio/wasmer/issues/1840)
|
/// [Closures as host functions tracking issue](https://github.com/wasmerio/wasmer/issues/1840)
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct Function(pub(crate) function_impl::Function);
|
pub struct Function(pub(crate) function_impl::Function);
|
||||||
|
|
||||||
impl Function {
|
impl Function {
|
||||||
@@ -500,6 +500,8 @@ impl Function {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::cmp::Eq for Function {}
|
||||||
|
|
||||||
impl<'a> Exportable<'a> for Function {
|
impl<'a> Exportable<'a> for Function {
|
||||||
fn get_self_from_extern(_extern: &'a Extern) -> Result<&'a Self, ExportError> {
|
fn get_self_from_extern(_extern: &'a Extern) -> Result<&'a Self, ExportError> {
|
||||||
match _extern {
|
match _extern {
|
||||||
|
|||||||
8
lib/api/src/externals/global.rs
vendored
8
lib/api/src/externals/global.rs
vendored
@@ -19,7 +19,7 @@ use crate::sys::externals::global as global_impl;
|
|||||||
/// It consists of an individual value and a flag indicating whether it is mutable.
|
/// It consists of an individual value and a flag indicating whether it is mutable.
|
||||||
///
|
///
|
||||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#global-instances>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#global-instances>
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct Global(pub(crate) global_impl::Global);
|
pub struct Global(pub(crate) global_impl::Global);
|
||||||
|
|
||||||
impl Global {
|
impl Global {
|
||||||
@@ -161,12 +161,6 @@ impl Global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::cmp::PartialEq for Global {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.0 == other.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::cmp::Eq for Global {}
|
impl std::cmp::Eq for Global {}
|
||||||
|
|
||||||
impl<'a> Exportable<'a> for Global {
|
impl<'a> Exportable<'a> for Global {
|
||||||
|
|||||||
8
lib/api/src/externals/memory.rs
vendored
8
lib/api/src/externals/memory.rs
vendored
@@ -27,7 +27,7 @@ use wasmer_types::{MemoryError, Pages};
|
|||||||
/// mutable from both host and WebAssembly.
|
/// mutable from both host and WebAssembly.
|
||||||
///
|
///
|
||||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances>
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct Memory(pub(crate) memory_impl::Memory);
|
pub struct Memory(pub(crate) memory_impl::Memory);
|
||||||
|
|
||||||
impl Memory {
|
impl Memory {
|
||||||
@@ -148,12 +148,6 @@ impl Memory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::cmp::PartialEq for Memory {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.0 == other.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::cmp::Eq for Memory {}
|
impl std::cmp::Eq for Memory {}
|
||||||
|
|
||||||
impl<'a> Exportable<'a> for Memory {
|
impl<'a> Exportable<'a> for Memory {
|
||||||
|
|||||||
2
lib/api/src/externals/mod.rs
vendored
2
lib/api/src/externals/mod.rs
vendored
@@ -25,7 +25,7 @@ use crate::store::{AsStoreMut, AsStoreRef};
|
|||||||
/// can be imported or exported.
|
/// can be imported or exported.
|
||||||
///
|
///
|
||||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#external-values>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#external-values>
|
||||||
#[derive(Clone)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub enum Extern {
|
pub enum Extern {
|
||||||
/// A external [`Function`].
|
/// A external [`Function`].
|
||||||
Function(Function),
|
Function(Function),
|
||||||
|
|||||||
8
lib/api/src/externals/table.rs
vendored
8
lib/api/src/externals/table.rs
vendored
@@ -20,7 +20,7 @@ use crate::Value;
|
|||||||
/// mutable from both host and WebAssembly.
|
/// mutable from both host and WebAssembly.
|
||||||
///
|
///
|
||||||
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#table-instances>
|
/// Spec: <https://webassembly.github.io/spec/core/exec/runtime.html#table-instances>
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct Table(pub(crate) table_impl::Table);
|
pub struct Table(pub(crate) table_impl::Table);
|
||||||
|
|
||||||
impl Table {
|
impl Table {
|
||||||
@@ -113,12 +113,6 @@ impl Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::cmp::PartialEq for Table {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.0 == other.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::cmp::Eq for Table {}
|
impl std::cmp::Eq for Table {}
|
||||||
|
|
||||||
impl<'a> Exportable<'a> for Table {
|
impl<'a> Exportable<'a> for Table {
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ macro_rules! import_namespace {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::store::{AsStoreMut, Store};
|
use crate::store::Store;
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use crate::Extern;
|
use crate::Extern;
|
||||||
use crate::Global;
|
use crate::Global;
|
||||||
|
|||||||
2
lib/api/src/js/externals/table.rs
vendored
2
lib/api/src/js/externals/table.rs
vendored
@@ -23,7 +23,7 @@ fn get_function(store: &mut impl AsStoreMut, val: Value) -> Result<Function, Run
|
|||||||
match val {
|
match val {
|
||||||
Value::FuncRef(Some(ref func)) => Ok(func.0.handle.function.clone().into()),
|
Value::FuncRef(Some(ref func)) => Ok(func.0.handle.function.clone().into()),
|
||||||
// Only funcrefs is supported by the spec atm
|
// Only funcrefs is supported by the spec atm
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!("The {val:?} is not yet supported"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
lib/api/src/sys/externals/function.rs
vendored
2
lib/api/src/sys/externals/function.rs
vendored
@@ -14,7 +14,7 @@ use wasmer_vm::{
|
|||||||
VMFunction, VMFunctionBody, VMFunctionContext, VMFunctionKind, VMTrampoline,
|
VMFunction, VMFunctionBody, VMFunctionContext, VMFunctionKind, VMTrampoline,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct Function {
|
pub struct Function {
|
||||||
pub(crate) handle: StoreHandle<VMFunction>,
|
pub(crate) handle: StoreHandle<VMFunction>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn check_customtunables() -> Result<(), Box<dyn std::error::Error>> {
|
fn check_customtunables() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
use crate::{imports, wat2wasm, Instance, Memory, Module, Store};
|
use crate::{imports, wat2wasm, Engine, Instance, Memory, Module, Store};
|
||||||
use wasmer_compiler_cranelift::Cranelift;
|
use wasmer_compiler_cranelift::Cranelift;
|
||||||
|
|
||||||
let wasm_bytes = wat2wasm(
|
let wasm_bytes = wat2wasm(
|
||||||
@@ -242,7 +242,9 @@ mod tests {
|
|||||||
let compiler = Cranelift::default();
|
let compiler = Cranelift::default();
|
||||||
|
|
||||||
let tunables = TinyTunables {};
|
let tunables = TinyTunables {};
|
||||||
let mut store = Store::new_with_tunables(compiler, tunables);
|
let mut engine = Engine::new(compiler.into(), Default::default(), Default::default());
|
||||||
|
engine.set_tunables(tunables);
|
||||||
|
let mut store = Store::new(engine);
|
||||||
//let mut store = Store::new(compiler);
|
//let mut store = Store::new(compiler);
|
||||||
let module = Module::new(&store, wasm_bytes)?;
|
let module = Module::new(&store, wasm_bytes)?;
|
||||||
let import_object = imports! {};
|
let import_object = imports! {};
|
||||||
|
|||||||
Reference in New Issue
Block a user