mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 21:28:21 +00:00
feat(api) Rewrite the wasm_extern_type macro to avoid repetition.
This commit is contained in:
28
lib/api/src/externals/function.rs
vendored
28
lib/api/src/externals/function.rs
vendored
@@ -501,7 +501,8 @@ mod inner {
|
||||
}
|
||||
|
||||
macro_rules! wasm_extern_type {
|
||||
($type:ty => $native_type:ty) => {
|
||||
( $( $type:ty => $native_type:ty ),* ) => {
|
||||
$(
|
||||
#[allow(clippy::use_self)]
|
||||
unsafe impl WasmExternType for $type {
|
||||
type Native = $native_type;
|
||||
@@ -516,19 +517,22 @@ mod inner {
|
||||
self as _
|
||||
}
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
wasm_extern_type!(i8 => i32);
|
||||
wasm_extern_type!(u8 => i32);
|
||||
wasm_extern_type!(i16 => i32);
|
||||
wasm_extern_type!(u16 => i32);
|
||||
wasm_extern_type!(i32 => i32);
|
||||
wasm_extern_type!(u32 => i32);
|
||||
wasm_extern_type!(i64 => i64);
|
||||
wasm_extern_type!(u64 => i64);
|
||||
wasm_extern_type!(f32 => f32);
|
||||
wasm_extern_type!(f64 => f64);
|
||||
wasm_extern_type!(
|
||||
i8 => i32,
|
||||
u8 => i32,
|
||||
i16 => i32,
|
||||
u16 => i32,
|
||||
i32 => i32,
|
||||
u32 => i32,
|
||||
i64 => i64,
|
||||
u64 => i64,
|
||||
f32 => f32,
|
||||
f64 => f64
|
||||
);
|
||||
|
||||
/// Represents a list of WebAssembly values.
|
||||
pub trait WasmTypeList {
|
||||
@@ -918,7 +922,7 @@ mod inner {
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[cfg(test)]
|
||||
mod test_func {
|
||||
mod test_function {
|
||||
use super::*;
|
||||
use wasm_common::Type;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user