mirror of
https://github.com/fluencelabs/marine.git
synced 2025-03-14 21:40:49 +00:00
add get_func_no_args to Exports trait
This commit is contained in:
parent
2d93770688
commit
d9f9288e1e
@ -66,15 +66,10 @@ pub trait Exports<WB: WasmBackend> {
|
||||
name: &str,
|
||||
) -> wasmer_core::error::ResolveResult<T>;
|
||||
|
||||
fn get_func<'a, Args: wasmer_core::types::WasmExternType, Rets: wasmer_core::types::WasmExternType>(
|
||||
fn get_func_no_args<'a, Rets: wasmer_core::typed_func::WasmTypeList + 'a>(
|
||||
&'a self,
|
||||
name: &str,
|
||||
) -> wasmer_core::error::ResolveResult<Box<dyn Fn(i32) -> ()/*wasmer_core::error::RuntimeResult<Rets>*/ + 'a>>;// wasmer_core::error::ResolveResult<Box<dyn Fn(Args) -> wasmer_core::error::RuntimeResult<Rets> + 'a>>;
|
||||
|
||||
fn get_func2<'a, Args>(
|
||||
&'a self,
|
||||
name: &str,
|
||||
) -> Box<dyn Fn(Args) -> ()>;
|
||||
) -> wasmer_core::error::ResolveResult<Box<dyn Fn() -> wasmer_core::error::RuntimeResult<Rets> + 'a>>;
|
||||
}
|
||||
|
||||
pub enum Export<M: MemoryExport, F: FunctionExport> {
|
||||
|
@ -20,6 +20,7 @@ use wasmer_core::error::{ResolveError, ResolveResult};
|
||||
use wasmer_core::fault::raw::longjmp;
|
||||
use wasmer_core::Func;
|
||||
use wasmer_core::module::ExportIndex;
|
||||
use wasmer_core::typed_func::WasmTypeList;
|
||||
//use wasmer_core::prelude::vm::Ctx;
|
||||
use wasmer_core::types::{FuncSig, LocalOrImport, WasmExternType};
|
||||
use wasmer_wasi::state::WasiState;
|
||||
@ -237,30 +238,25 @@ impl Exports<WasmerBackend> for WasmerInstance {
|
||||
self.instance.exports.get(name)
|
||||
}
|
||||
|
||||
fn get_func<'a, Args: WasmExternType, Rets: WasmExternType>(
|
||||
fn get_func_no_args<'a, Rets: WasmTypeList + 'a>(
|
||||
&'a self,
|
||||
name: &str,
|
||||
) -> wasmer_core::error::ResolveResult<Box<dyn Fn(i32) -> () +'a>> {
|
||||
) -> wasmer_core::error::ResolveResult<
|
||||
Box<dyn Fn() -> wasmer_core::error::RuntimeResult<Rets> + 'a>,
|
||||
> {
|
||||
self.instance
|
||||
.exports
|
||||
.get::<Func<'a, Args, Rets>>(name)
|
||||
.map(|_| {
|
||||
let func = |args: i32| -> () {};
|
||||
|
||||
Box::new(func)
|
||||
.get::<Func<'a, (), Rets>>(name)
|
||||
.map(|func| {
|
||||
let func: Box<dyn Fn() -> wasmer_core::error::RuntimeResult<Rets> + 'a> =
|
||||
Box::new(
|
||||
move || -> wasmer_core::error::RuntimeResult<Rets> {
|
||||
func.call()
|
||||
},
|
||||
);
|
||||
func
|
||||
})
|
||||
}
|
||||
|
||||
fn get_func2<'a, Args>(
|
||||
&'a self,
|
||||
name: &str,
|
||||
) -> Box<dyn Fn(Args) -> ()/*wasmer_core::error::RuntimeResult<Rets>*/> {
|
||||
let func = move |args: Args| -> () /*wasmer_core::error::RuntimeResult<Rets>*/ {
|
||||
//func.call(args)
|
||||
};
|
||||
|
||||
Box::new(func)
|
||||
}
|
||||
}
|
||||
|
||||
fn export_from_wasmer_export(
|
||||
|
@ -148,8 +148,8 @@ impl<WB: WasmBackend> MModule<WB> {
|
||||
|
||||
// call _start to populate the WASI state of the module
|
||||
#[rustfmt::skip]
|
||||
if let Ok(start_func) = wasmer_instance.exports().get::<wasmer_runtime::Func<'_, (), ()>>("_start") {
|
||||
start_func.call()?;
|
||||
if let Ok(start_func) = wasmer_instance.exports().get_func_no_args::<'_, ()>("_start") {
|
||||
start_func()?;
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
|
Loading…
x
Reference in New Issue
Block a user