1
0
mirror of https://github.com/fluencelabs/wasmer synced 2025-07-27 13:22:00 +00:00

Merge branch 'master' into fix/update-debug-macro

This commit is contained in:
Lachlan Sneff
2019-01-29 15:58:51 -08:00
committed by GitHub
42 changed files with 2600 additions and 2721 deletions

@@ -13,8 +13,8 @@ macro_rules! debug {
}
#[macro_export]
macro_rules! export_func {
($func:ident, [ $( $params:ident ),* ] -> [ $( $returns:ident ),* ]) => {{
macro_rules! func {
($func:ident, [ $( $params:ident ),* ] -> [ $( $returns:ident ),* ] ) => {{
use $crate::{
export::{Context, Export, FuncPointer},
types::{FuncSig, Type},
@@ -26,10 +26,10 @@ macro_rules! export_func {
Export::Function {
func: unsafe { FuncPointer::new(func as _) },
ctx: Context::Internal,
signature: FuncSig {
params: vec![$($crate::__export_func_convert_type!($params),)*],
returns: vec![$($crate::__export_func_convert_type!($returns),)*],
},
signature: FuncSig::new(
&[$($crate::__export_func_convert_type!($params),)*] as &[Type],
&[$($crate::__export_func_convert_type!($returns),)*] as &[Type],
).into(),
}
}};
}
@@ -71,11 +71,11 @@ macro_rules! __export_func_convert_type {
///
/// # Usage:
/// ```
/// # use wasmer_runtime_core::imports;
/// # use wasmer_runtime_core::{imports, func};
/// # use wasmer_runtime_core::vm::Ctx;
/// let import_object = imports! {
/// "env" => {
/// "foo" => foo<[i32] -> [i32]>,
/// "foo" => func!(foo, [i32] -> [i32]),
/// },
/// };
///
@@ -105,13 +105,10 @@ macro_rules! imports {
#[macro_export]
#[doc(hidden)]
macro_rules! __imports_internal {
( { $( $imp_name:expr => $func:ident < [ $( $params:ident ),* ] -> [ $( $returns:ident ),* ] >, )* } ) => {{
( { $( $imp_name:expr => $import_item:expr, )* } ) => {{
let mut ns = Namespace::new();
$(
ns.insert($imp_name, $crate::export_func!(
$func,
[ $( $params ),* ] -> [ $( $returns )* ]
));
ns.insert($imp_name, $import_item);
)*
ns
}};