feat(api) Rewrite the wasm_extern_type macro to avoid repetition.

This commit is contained in:
Ivan Enderlin
2020-06-22 11:46:30 +02:00
parent 58c83734f2
commit ef3e43dcff

View File

@@ -501,7 +501,8 @@ mod inner {
} }
macro_rules! wasm_extern_type { macro_rules! wasm_extern_type {
($type:ty => $native_type:ty) => { ( $( $type:ty => $native_type:ty ),* ) => {
$(
#[allow(clippy::use_self)] #[allow(clippy::use_self)]
unsafe impl WasmExternType for $type { unsafe impl WasmExternType for $type {
type Native = $native_type; type Native = $native_type;
@@ -516,19 +517,22 @@ mod inner {
self as _ self as _
} }
} }
)*
}; };
} }
wasm_extern_type!(i8 => i32); wasm_extern_type!(
wasm_extern_type!(u8 => i32); i8 => i32,
wasm_extern_type!(i16 => i32); u8 => i32,
wasm_extern_type!(u16 => i32); i16 => i32,
wasm_extern_type!(i32 => i32); u16 => i32,
wasm_extern_type!(u32 => i32); i32 => i32,
wasm_extern_type!(i64 => i64); u32 => i32,
wasm_extern_type!(u64 => i64); i64 => i64,
wasm_extern_type!(f32 => f32); u64 => i64,
wasm_extern_type!(f64 => f64); f32 => f32,
f64 => f64
);
/// Represents a list of WebAssembly values. /// Represents a list of WebAssembly values.
pub trait WasmTypeList { pub trait WasmTypeList {
@@ -918,7 +922,7 @@ mod inner {
#[allow(non_snake_case)] #[allow(non_snake_case)]
#[cfg(test)] #[cfg(test)]
mod test_func { mod test_function {
use super::*; use super::*;
use wasm_common::Type; use wasm_common::Type;