mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 22:28:21 +00:00
c-api: Add wasm_*_same functions to global,memory,table
This commit is contained in:
8
lib/api/src/sys/externals/global.rs
vendored
8
lib/api/src/sys/externals/global.rs
vendored
@@ -222,6 +222,14 @@ impl Global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::cmp::PartialEq for Global {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.handle == other.handle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::cmp::Eq for Global {}
|
||||||
|
|
||||||
impl<'a> Exportable<'a> for Global {
|
impl<'a> Exportable<'a> for Global {
|
||||||
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/sys/externals/memory.rs
vendored
8
lib/api/src/sys/externals/memory.rs
vendored
@@ -239,6 +239,14 @@ impl Memory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::cmp::PartialEq for Memory {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.handle == other.handle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::cmp::Eq for Memory {}
|
||||||
|
|
||||||
impl<'a> Exportable<'a> for Memory {
|
impl<'a> Exportable<'a> for Memory {
|
||||||
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/sys/externals/table.rs
vendored
8
lib/api/src/sys/externals/table.rs
vendored
@@ -196,6 +196,14 @@ impl Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::cmp::PartialEq for Table {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.handle == other.handle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::cmp::Eq for Table {}
|
||||||
|
|
||||||
impl<'a> Exportable<'a> for Table {
|
impl<'a> Exportable<'a> for Table {
|
||||||
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/c-api/src/wasm_c_api/externals/global.rs
vendored
8
lib/c-api/src/wasm_c_api/externals/global.rs
vendored
@@ -99,6 +99,14 @@ pub unsafe extern "C" fn wasm_global_set(global: &mut wasm_global_t, val: &wasm_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn wasm_global_same(
|
||||||
|
wasm_global1: &wasm_global_t,
|
||||||
|
wasm_global2: &wasm_global_t,
|
||||||
|
) -> bool {
|
||||||
|
wasm_global1.inner == wasm_global2.inner
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_global_type(
|
pub extern "C" fn wasm_global_type(
|
||||||
global: Option<&wasm_global_t>,
|
global: Option<&wasm_global_t>,
|
||||||
|
|||||||
8
lib/c-api/src/wasm_c_api/externals/memory.rs
vendored
8
lib/c-api/src/wasm_c_api/externals/memory.rs
vendored
@@ -53,6 +53,14 @@ pub unsafe extern "C" fn wasm_memory_copy(memory: &wasm_memory_t) -> Box<wasm_me
|
|||||||
Box::new(wasm_memory_t::new((&*memory.inner).clone()))
|
Box::new(wasm_memory_t::new((&*memory.inner).clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn wasm_memory_same(
|
||||||
|
wasm_memory1: &wasm_memory_t,
|
||||||
|
wasm_memory2: &wasm_memory_t,
|
||||||
|
) -> bool {
|
||||||
|
wasm_memory1.inner == wasm_memory2.inner
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_memory_type(
|
pub unsafe extern "C" fn wasm_memory_type(
|
||||||
memory: Option<&wasm_memory_t>,
|
memory: Option<&wasm_memory_t>,
|
||||||
|
|||||||
8
lib/c-api/src/wasm_c_api/externals/table.rs
vendored
8
lib/c-api/src/wasm_c_api/externals/table.rs
vendored
@@ -53,6 +53,14 @@ pub unsafe extern "C" fn wasm_table_size(table: &wasm_table_t) -> usize {
|
|||||||
table.inner.size(&ctx.inner) as _
|
table.inner.size(&ctx.inner) as _
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn wasm_table_same(
|
||||||
|
wasm_table1: &wasm_table_t,
|
||||||
|
wasm_table2: &wasm_table_t,
|
||||||
|
) -> bool {
|
||||||
|
wasm_table1.inner == wasm_table2.inner
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasm_table_grow(
|
pub unsafe extern "C" fn wasm_table_grow(
|
||||||
_table: &mut wasm_table_t,
|
_table: &mut wasm_table_t,
|
||||||
|
|||||||
@@ -123,6 +123,14 @@ impl<T: ContextObject> fmt::Debug for ContextHandle<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: ContextObject> PartialEq for ContextHandle<T> {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.id == other.id && self.internal == other.internal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: ContextObject> Eq for ContextHandle<T> {}
|
||||||
|
|
||||||
impl<T: ContextObject> ContextHandle<T> {
|
impl<T: ContextObject> ContextHandle<T> {
|
||||||
/// Moves the given object into a context and returns a handle to it.
|
/// Moves the given object into a context and returns a handle to it.
|
||||||
pub fn new(ctx: &mut ContextObjects, val: T) -> Self {
|
pub fn new(ctx: &mut ContextObjects, val: T) -> Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user