mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 14:18:20 +00:00
Renamed get_native_function to get_typed_function, marked former as deprecated.
This commit is contained in:
@@ -14,6 +14,7 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C
|
|||||||
- [#2999](https://github.com/wasmerio/wasmer/pull/2999) Allow `--invoke` CLI option for Emscripten files without a `main` function
|
- [#2999](https://github.com/wasmerio/wasmer/pull/2999) Allow `--invoke` CLI option for Emscripten files without a `main` function
|
||||||
- [#2946](https://github.com/wasmerio/wasmer/pull/2946) Remove dylib,staticlib engines in favor of a single Universal engine
|
- [#2946](https://github.com/wasmerio/wasmer/pull/2946) Remove dylib,staticlib engines in favor of a single Universal engine
|
||||||
- [#2949](https://github.com/wasmerio/wasmer/pull/2949) Switch back to using custom LLVM builds on CI
|
- [#2949](https://github.com/wasmerio/wasmer/pull/2949) Switch back to using custom LLVM builds on CI
|
||||||
|
- #2892 Renamed `get_native_function` to `get_typed_function`, marked former as deprecated.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- [#2963](https://github.com/wasmerio/wasmer/pull/2963) Remove accidental dependency on libwayland and libxcb in ClI
|
- [#2963](https://github.com/wasmerio/wasmer/pull/2963) Remove accidental dependency on libwayland and libxcb in ClI
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
//
|
//
|
||||||
// Get the `run` function which we'll use as our entrypoint.
|
// Get the `run` function which we'll use as our entrypoint.
|
||||||
println!("Calling `run` function...");
|
println!("Calling `run` function...");
|
||||||
let run_func: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("run")?;
|
let run_func: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("run")?;
|
||||||
|
|
||||||
// When we call a function it can either succeed or fail. We expect it to fail.
|
// When we call a function it can either succeed or fail. We expect it to fail.
|
||||||
match run_func.call(1, 7) {
|
match run_func.call(1, 7) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
let load = instance
|
let load = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function::<(), (WasmPtr<u8>, i32)>("load")?;
|
.get_typed_function::<(), (WasmPtr<u8>, i32)>("load")?;
|
||||||
|
|
||||||
// Here we go.
|
// Here we go.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// Recall that the Wasm module exported a function named "run", this is getting
|
// Recall that the Wasm module exported a function named "run", this is getting
|
||||||
// that exported function from the `Instance`.
|
// that exported function from the `Instance`.
|
||||||
let run_func: TypedFunction<(), ()> =
|
let run_func: TypedFunction<(), ()> =
|
||||||
instance.exports.get_native_function(&mut context, "run")?;
|
instance.exports.get_typed_function(&mut context, "run")?;
|
||||||
|
|
||||||
// Finally, we call our exported Wasm function which will call our "say_hello"
|
// Finally, we call our exported Wasm function which will call our "say_hello"
|
||||||
// function and return.
|
// function and return.
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// The module exports some utility functions, let's get them.
|
// The module exports some utility functions, let's get them.
|
||||||
//
|
//
|
||||||
// These function will be used later in this example.
|
// These function will be used later in this example.
|
||||||
let mem_size: TypedFunction<(), i32> = instance.exports.get_native_function("mem_size")?;
|
let mem_size: TypedFunction<(), i32> = instance.exports.get_typed_function("mem_size")?;
|
||||||
let get_at: TypedFunction<i32, i32> = instance.exports.get_native_function("get_at")?;
|
let get_at: TypedFunction<i32, i32> = instance.exports.get_typed_function("get_at")?;
|
||||||
let set_at: TypedFunction<(i32, i32), ()> = instance.exports.get_native_function("set_at")?;
|
let set_at: TypedFunction<(i32, i32), ()> = instance.exports.get_typed_function("set_at")?;
|
||||||
let memory = instance.exports.get_memory("memory")?;
|
let memory = instance.exports.get_memory("memory")?;
|
||||||
|
|
||||||
// We now have an instance ready to be used.
|
// We now have an instance ready to be used.
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// The first argument is the table index and the next 2 are the 2 arguments
|
// The first argument is the table index and the next 2 are the 2 arguments
|
||||||
// to be passed to the function found in the table.
|
// to be passed to the function found in the table.
|
||||||
let call_via_table: TypedFunction<(i32, i32, i32), i32> =
|
let call_via_table: TypedFunction<(i32, i32, i32), i32> =
|
||||||
instance.exports.get_native_function("call_callback")?;
|
instance.exports.get_typed_function("call_callback")?;
|
||||||
|
|
||||||
// And then call it with table index 1 and arguments 2 and 7.
|
// And then call it with table index 1 and arguments 2 and 7.
|
||||||
let result = call_via_table.call(1, 2, 7)?;
|
let result = call_via_table.call(1, 2, 7)?;
|
||||||
|
|||||||
@@ -134,11 +134,27 @@ impl Exports {
|
|||||||
self.get(name)
|
self.get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(
|
||||||
|
since = "3.0.0",
|
||||||
|
note = "get_native_function() has been renamed to get_typed_function(), just like NativeFunc has been renamed to TypedFunction."
|
||||||
|
)]
|
||||||
/// Get an export as a `TypedFunction`.
|
/// Get an export as a `TypedFunction`.
|
||||||
pub fn get_native_function<Args, Rets>(
|
pub fn get_native_function<Args, Rets>(
|
||||||
&self,
|
&self,
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Result<TypedFunction<Args, Rets>, ExportError>
|
) -> Result<TypedFunction<Args, Rets>, ExportError>
|
||||||
|
where
|
||||||
|
Args: WasmTypeList,
|
||||||
|
Rets: WasmTypeList,
|
||||||
|
{
|
||||||
|
self.get_typed_function(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get an export as a `TypedFunction`.
|
||||||
|
pub fn get_typed_function<Args, Rets>(
|
||||||
|
&self,
|
||||||
|
name: &str,
|
||||||
|
) -> Result<TypedFunction<Args, Rets>, ExportError>
|
||||||
where
|
where
|
||||||
Args: WasmTypeList,
|
Args: WasmTypeList,
|
||||||
Rets: WasmTypeList,
|
Rets: WasmTypeList,
|
||||||
|
|||||||
@@ -170,7 +170,7 @@
|
|||||||
//! # fn exports_example(instance: &Instance) -> anyhow::Result<()> {
|
//! # fn exports_example(instance: &Instance) -> anyhow::Result<()> {
|
||||||
//! let memory = instance.exports.get_memory("memory")?;
|
//! let memory = instance.exports.get_memory("memory")?;
|
||||||
//! let memory: &Memory = instance.exports.get("some_other_memory")?;
|
//! let memory: &Memory = instance.exports.get("some_other_memory")?;
|
||||||
//! let add: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("add")?;
|
//! let add: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("add")?;
|
||||||
//! let result = add.call(5, 37)?;
|
//! let result = add.call(5, 37)?;
|
||||||
//! assert_eq!(result, 42);
|
//! assert_eq!(result, 42);
|
||||||
//! # Ok(())
|
//! # Ok(())
|
||||||
|
|||||||
@@ -134,12 +134,29 @@ impl Exports {
|
|||||||
self.get(name)
|
self.get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(
|
||||||
|
since = "3.0.0",
|
||||||
|
note = "get_native_function() has been renamed to get_typed_function(), just like NativeFunc has been renamed to TypedFunction."
|
||||||
|
)]
|
||||||
/// Get an export as a `TypedFunction`.
|
/// Get an export as a `TypedFunction`.
|
||||||
pub fn get_native_function<Args, Rets>(
|
pub fn get_native_function<Args, Rets>(
|
||||||
&self,
|
&self,
|
||||||
ctx: &impl AsContextRef,
|
ctx: &impl AsContextRef,
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Result<TypedFunction<Args, Rets>, ExportError>
|
) -> Result<TypedFunction<Args, Rets>, ExportError>
|
||||||
|
where
|
||||||
|
Args: WasmTypeList,
|
||||||
|
Rets: WasmTypeList,
|
||||||
|
{
|
||||||
|
self.get_typed_function(ctx, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get an export as a `TypedFunction`.
|
||||||
|
pub fn get_typed_function<Args, Rets>(
|
||||||
|
&self,
|
||||||
|
ctx: &impl AsContextRef,
|
||||||
|
name: &str,
|
||||||
|
) -> Result<TypedFunction<Args, Rets>, ExportError>
|
||||||
where
|
where
|
||||||
Args: WasmTypeList,
|
Args: WasmTypeList,
|
||||||
Rets: WasmTypeList,
|
Rets: WasmTypeList,
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ mod js {
|
|||||||
let instance = Instance::new(&module, &import_object).unwrap();
|
let instance = Instance::new(&module, &import_object).unwrap();
|
||||||
|
|
||||||
let add_one: TypedFunction<i32, i32> =
|
let add_one: TypedFunction<i32, i32> =
|
||||||
instance.exports.get_native_function("add_one").unwrap();
|
instance.exports.get_typed_function("add_one").unwrap();
|
||||||
assert_eq!(add_one.call(1), Ok(2));
|
assert_eq!(add_one.call(1), Ok(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,7 +646,7 @@ mod js {
|
|||||||
let instance = Instance::new(&module, &import_object).unwrap();
|
let instance = Instance::new(&module, &import_object).unwrap();
|
||||||
|
|
||||||
let run_func: TypedFunction<(i32, i32), i32> =
|
let run_func: TypedFunction<(i32, i32), i32> =
|
||||||
instance.exports.get_native_function("run").unwrap();
|
instance.exports.get_typed_function("run").unwrap();
|
||||||
|
|
||||||
assert!(run_func.call(1, 7).is_err(), "Expected early termination",);
|
assert!(run_func.call(1, 7).is_err(), "Expected early termination",);
|
||||||
let run_func = instance.exports.get_function("run").unwrap();
|
let run_func = instance.exports.get_function("run").unwrap();
|
||||||
@@ -725,7 +725,7 @@ mod js {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let run_func: TypedFunction<(i32, i32), i32> =
|
let run_func: TypedFunction<(i32, i32), i32> =
|
||||||
instance.exports.get_native_function("run").unwrap();
|
instance.exports.get_typed_function("run").unwrap();
|
||||||
test_result(run_func.call(1, 7));
|
test_result(run_func.call(1, 7));
|
||||||
|
|
||||||
let run_func = instance.exports.get_function("run").unwrap();
|
let run_func = instance.exports.get_function("run").unwrap();
|
||||||
|
|||||||
@@ -251,35 +251,35 @@ mod js {
|
|||||||
|
|
||||||
// let f1: TypedFunction<(), ()> = instance
|
// let f1: TypedFunction<(), ()> = instance
|
||||||
// .exports
|
// .exports
|
||||||
// .get_native_function("call_host_func1")
|
// .get_typed_function("call_host_func1")
|
||||||
// .unwrap();
|
// .unwrap();
|
||||||
// let f2: TypedFunction<(), ()> = instance
|
// let f2: TypedFunction<(), ()> = instance
|
||||||
// .exports
|
// .exports
|
||||||
// .get_native_function("call_host_func2")
|
// .get_typed_function("call_host_func2")
|
||||||
// .unwrap();
|
// .unwrap();
|
||||||
// let f3: TypedFunction<(), ()> = instance
|
// let f3: TypedFunction<(), ()> = instance
|
||||||
// .exports
|
// .exports
|
||||||
// .get_native_function("call_host_func3")
|
// .get_typed_function("call_host_func3")
|
||||||
// .unwrap();
|
// .unwrap();
|
||||||
// let f4: TypedFunction<(), ()> = instance
|
// let f4: TypedFunction<(), ()> = instance
|
||||||
// .exports
|
// .exports
|
||||||
// .get_native_function("call_host_func4")
|
// .get_typed_function("call_host_func4")
|
||||||
// .unwrap();
|
// .unwrap();
|
||||||
// let f5: TypedFunction<(), ()> = instance
|
// let f5: TypedFunction<(), ()> = instance
|
||||||
// .exports
|
// .exports
|
||||||
// .get_native_function("call_host_func5")
|
// .get_typed_function("call_host_func5")
|
||||||
// .unwrap();
|
// .unwrap();
|
||||||
// let f6: TypedFunction<(), ()> = instance
|
// let f6: TypedFunction<(), ()> = instance
|
||||||
// .exports
|
// .exports
|
||||||
// .get_native_function("call_host_func6")
|
// .get_typed_function("call_host_func6")
|
||||||
// .unwrap();
|
// .unwrap();
|
||||||
// let f7: TypedFunction<(), ()> = instance
|
// let f7: TypedFunction<(), ()> = instance
|
||||||
// .exports
|
// .exports
|
||||||
// .get_native_function("call_host_func7")
|
// .get_typed_function("call_host_func7")
|
||||||
// .unwrap();
|
// .unwrap();
|
||||||
// let f8: TypedFunction<(), ()> = instance
|
// let f8: TypedFunction<(), ()> = instance
|
||||||
// .exports
|
// .exports
|
||||||
// .get_native_function("call_host_func8")
|
// .get_typed_function("call_host_func8")
|
||||||
// .unwrap();
|
// .unwrap();
|
||||||
|
|
||||||
// f1.call().unwrap();
|
// f1.call().unwrap();
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ mod sys {
|
|||||||
assert_eq!(is_memory_instance_ref_strong(mem), Some(true));
|
assert_eq!(is_memory_instance_ref_strong(mem), Some(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
let f: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_fn")?;
|
let f: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_fn")?;
|
||||||
f.call()?;
|
f.call()?;
|
||||||
f
|
f
|
||||||
};
|
};
|
||||||
@@ -183,7 +183,7 @@ mod sys {
|
|||||||
assert_eq!(is_global_instance_ref_strong(global), Some(true));
|
assert_eq!(is_global_instance_ref_strong(global), Some(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
let f: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_fn")?;
|
let f: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_fn")?;
|
||||||
f.call()?;
|
f.call()?;
|
||||||
f
|
f
|
||||||
};
|
};
|
||||||
@@ -227,7 +227,7 @@ mod sys {
|
|||||||
assert_eq!(is_table_instance_ref_strong(table), Some(true));
|
assert_eq!(is_table_instance_ref_strong(table), Some(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
let f: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_fn")?;
|
let f: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_fn")?;
|
||||||
f.call()?;
|
f.call()?;
|
||||||
f
|
f
|
||||||
};
|
};
|
||||||
@@ -271,7 +271,7 @@ mod sys {
|
|||||||
assert_eq!(is_function_instance_ref_strong(function), Some(true));
|
assert_eq!(is_function_instance_ref_strong(function), Some(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
let f: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_fn")?;
|
let f: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_fn")?;
|
||||||
f.call()?;
|
f.call()?;
|
||||||
f
|
f
|
||||||
};
|
};
|
||||||
@@ -321,14 +321,14 @@ mod sys {
|
|||||||
|
|
||||||
{
|
{
|
||||||
let function: TypedFunction<(), ()> =
|
let function: TypedFunction<(), ()> =
|
||||||
instance.exports.get_native_function("call_host_fn")?;
|
instance.exports.get_typed_function("call_host_fn")?;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
is_native_function_instance_ref_strong(&function),
|
is_native_function_instance_ref_strong(&function),
|
||||||
Some(true)
|
Some(true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let f: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_fn")?;
|
let f: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_fn")?;
|
||||||
f.call()?;
|
f.call()?;
|
||||||
f
|
f
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ mod sys {
|
|||||||
let f = {
|
let f = {
|
||||||
let module = Module::new(&store, wat)?;
|
let module = Module::new(&store, wat)?;
|
||||||
let instance = Instance::new(&module, &imports! {})?;
|
let instance = Instance::new(&module, &imports! {})?;
|
||||||
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("sum")?;
|
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("sum")?;
|
||||||
|
|
||||||
assert_eq!(f.call(4, 5)?, 9);
|
assert_eq!(f.call(4, 5)?, 9);
|
||||||
f
|
f
|
||||||
|
|||||||
@@ -228,14 +228,14 @@ mod sys {
|
|||||||
};
|
};
|
||||||
let instance = Instance::new(&module, &imports)?;
|
let instance = Instance::new(&module, &imports)?;
|
||||||
|
|
||||||
let f1: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_func1")?;
|
let f1: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_func1")?;
|
||||||
let f2: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_func2")?;
|
let f2: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_func2")?;
|
||||||
let f3: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_func3")?;
|
let f3: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_func3")?;
|
||||||
let f4: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_func4")?;
|
let f4: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_func4")?;
|
||||||
let f5: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_func5")?;
|
let f5: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_func5")?;
|
||||||
let f6: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_func6")?;
|
let f6: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_func6")?;
|
||||||
let f7: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_func7")?;
|
let f7: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_func7")?;
|
||||||
let f8: TypedFunction<(), ()> = instance.exports.get_native_function("call_host_func8")?;
|
let f8: TypedFunction<(), ()> = instance.exports.get_typed_function("call_host_func8")?;
|
||||||
|
|
||||||
f1.call()?;
|
f1.call()?;
|
||||||
f2.call()?;
|
f2.call()?;
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ mod sys {
|
|||||||
{
|
{
|
||||||
let f: TypedFunction<(), i32> = instance
|
let f: TypedFunction<(), i32> = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function("call_host_func_with_wasm_func")?;
|
.get_typed_function("call_host_func_with_wasm_func")?;
|
||||||
let result = f.call()?;
|
let result = f.call()?;
|
||||||
assert_eq!(result, 63);
|
assert_eq!(result, 63);
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ mod sys {
|
|||||||
panic!("result is not an extern ref!");
|
panic!("result is not an extern ref!");
|
||||||
}
|
}
|
||||||
|
|
||||||
let f: TypedFunction<(), ExternRef> = instance.exports.get_native_function(run)?;
|
let f: TypedFunction<(), ExternRef> = instance.exports.get_typed_function(run)?;
|
||||||
let result: ExternRef = f.call()?;
|
let result: ExternRef = f.call()?;
|
||||||
assert!(result.is_null());
|
assert!(result.is_null());
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ mod sys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let f: TypedFunction<(), ExternRef> =
|
let f: TypedFunction<(), ExternRef> =
|
||||||
instance.exports.get_native_function(get_hashmap)?;
|
instance.exports.get_typed_function(get_hashmap)?;
|
||||||
|
|
||||||
let result: ExternRef = f.call()?;
|
let result: ExternRef = f.call()?;
|
||||||
let inner: &HashMap<String, String> = result.downcast().unwrap();
|
let inner: &HashMap<String, String> = result.downcast().unwrap();
|
||||||
@@ -222,7 +222,7 @@ mod sys {
|
|||||||
)"#;
|
)"#;
|
||||||
let module = Module::new(&store, wat)?;
|
let module = Module::new(&store, wat)?;
|
||||||
let instance = Instance::new(&module, &imports! {})?;
|
let instance = Instance::new(&module, &imports! {})?;
|
||||||
let f: TypedFunction<ExternRef, ()> = instance.exports.get_native_function("drop")?;
|
let f: TypedFunction<ExternRef, ()> = instance.exports.get_typed_function("drop")?;
|
||||||
|
|
||||||
let er = ExternRef::new(3u32);
|
let er = ExternRef::new(3u32);
|
||||||
f.call(er.clone())?;
|
f.call(er.clone())?;
|
||||||
@@ -316,7 +316,7 @@ mod sys {
|
|||||||
let instance = Instance::new(&module, &imports! {})?;
|
let instance = Instance::new(&module, &imports! {})?;
|
||||||
|
|
||||||
let f: TypedFunction<(ExternRef, i32), ExternRef> =
|
let f: TypedFunction<(ExternRef, i32), ExternRef> =
|
||||||
instance.exports.get_native_function("insert_into_table")?;
|
instance.exports.get_typed_function("insert_into_table")?;
|
||||||
|
|
||||||
let er = ExternRef::new(3usize);
|
let er = ExternRef::new(3usize);
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ mod sys {
|
|||||||
assert_eq!(er.strong_count(), 2);
|
assert_eq!(er.strong_count(), 2);
|
||||||
}
|
}
|
||||||
let get_from_global: TypedFunction<(), ExternRef> =
|
let get_from_global: TypedFunction<(), ExternRef> =
|
||||||
instance.exports.get_native_function("get_from_global")?;
|
instance.exports.get_typed_function("get_from_global")?;
|
||||||
|
|
||||||
let er = get_from_global.call()?;
|
let er = get_from_global.call()?;
|
||||||
assert_eq!(er.strong_count(), 2);
|
assert_eq!(er.strong_count(), 2);
|
||||||
@@ -383,7 +383,7 @@ mod sys {
|
|||||||
let instance = Instance::new(&module, &imports! {})?;
|
let instance = Instance::new(&module, &imports! {})?;
|
||||||
|
|
||||||
let pass_extern_ref: TypedFunction<ExternRef, ()> =
|
let pass_extern_ref: TypedFunction<ExternRef, ()> =
|
||||||
instance.exports.get_native_function("pass_extern_ref")?;
|
instance.exports.get_typed_function("pass_extern_ref")?;
|
||||||
|
|
||||||
let er = ExternRef::new(3usize);
|
let er = ExternRef::new(3usize);
|
||||||
assert_eq!(er.strong_count(), 1);
|
assert_eq!(er.strong_count(), 1);
|
||||||
@@ -411,14 +411,12 @@ mod sys {
|
|||||||
let module = Module::new(&store, wat)?;
|
let module = Module::new(&store, wat)?;
|
||||||
let instance = Instance::new(&module, &imports! {})?;
|
let instance = Instance::new(&module, &imports! {})?;
|
||||||
|
|
||||||
let grow_table_with_ref: TypedFunction<(ExternRef, i32), i32> = instance
|
let grow_table_with_ref: TypedFunction<(ExternRef, i32), i32> =
|
||||||
.exports
|
instance.exports.get_typed_function("grow_table_with_ref")?;
|
||||||
.get_native_function("grow_table_with_ref")?;
|
let fill_table_with_ref: TypedFunction<(ExternRef, i32, i32), ()> =
|
||||||
let fill_table_with_ref: TypedFunction<(ExternRef, i32, i32), ()> = instance
|
instance.exports.get_typed_function("fill_table_with_ref")?;
|
||||||
.exports
|
|
||||||
.get_native_function("fill_table_with_ref")?;
|
|
||||||
let copy_into_table2: TypedFunction<(), ()> =
|
let copy_into_table2: TypedFunction<(), ()> =
|
||||||
instance.exports.get_native_function("copy_into_table2")?;
|
instance.exports.get_typed_function("copy_into_table2")?;
|
||||||
let table1: &Table = instance.exports.get_table("table1")?;
|
let table1: &Table = instance.exports.get_table("table1")?;
|
||||||
let table2: &Table = instance.exports.get_table("table2")?;
|
let table2: &Table = instance.exports.get_table("table2")?;
|
||||||
|
|
||||||
|
|||||||
@@ -602,234 +602,225 @@ pub fn run_emscripten_instance(
|
|||||||
env.set_memory(globals.memory.clone());
|
env.set_memory(globals.memory.clone());
|
||||||
// get emscripten export
|
// get emscripten export
|
||||||
let mut emfuncs = EmscriptenFunctions::new();
|
let mut emfuncs = EmscriptenFunctions::new();
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "malloc") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "malloc") {
|
||||||
emfuncs.malloc = Some(func);
|
emfuncs.malloc = Some(func);
|
||||||
} else if let Ok(func) = instance.exports.get_native_function(&ctx, "_malloc") {
|
} else if let Ok(func) = instance.exports.get_typed_function(&ctx, "_malloc") {
|
||||||
emfuncs.malloc = Some(func);
|
emfuncs.malloc = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "free") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "free") {
|
||||||
emfuncs.free = Some(func);
|
emfuncs.free = Some(func);
|
||||||
} else if let Ok(func) = instance.exports.get_native_function(&ctx, "_free") {
|
} else if let Ok(func) = instance.exports.get_typed_function(&ctx, "_free") {
|
||||||
emfuncs.free = Some(func);
|
emfuncs.free = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "memalign") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "memalign") {
|
||||||
emfuncs.memalign = Some(func);
|
emfuncs.memalign = Some(func);
|
||||||
} else if let Ok(func) = instance.exports.get_native_function(&ctx, "_memalign") {
|
} else if let Ok(func) = instance.exports.get_typed_function(&ctx, "_memalign") {
|
||||||
emfuncs.memalign = Some(func);
|
emfuncs.memalign = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "memset") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "memset") {
|
||||||
emfuncs.memset = Some(func);
|
emfuncs.memset = Some(func);
|
||||||
} else if let Ok(func) = instance.exports.get_native_function(&ctx, "_memset") {
|
} else if let Ok(func) = instance.exports.get_typed_function(&ctx, "_memset") {
|
||||||
emfuncs.memset = Some(func);
|
emfuncs.memset = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "stackAlloc") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "stackAlloc") {
|
||||||
emfuncs.stack_alloc = Some(func);
|
emfuncs.stack_alloc = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_i") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_i") {
|
||||||
emfuncs.dyn_call_i = Some(func);
|
emfuncs.dyn_call_i = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_ii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_ii") {
|
||||||
emfuncs.dyn_call_ii = Some(func);
|
emfuncs.dyn_call_ii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_iii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_iii") {
|
||||||
emfuncs.dyn_call_iii = Some(func);
|
emfuncs.dyn_call_iii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_iiii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_iiii") {
|
||||||
emfuncs.dyn_call_iiii = Some(func);
|
emfuncs.dyn_call_iiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_iifi") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_iifi") {
|
||||||
emfuncs.dyn_call_iifi = Some(func);
|
emfuncs.dyn_call_iifi = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_v") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_v") {
|
||||||
emfuncs.dyn_call_v = Some(func);
|
emfuncs.dyn_call_v = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_vi") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_vi") {
|
||||||
emfuncs.dyn_call_vi = Some(func);
|
emfuncs.dyn_call_vi = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_vii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_vii") {
|
||||||
emfuncs.dyn_call_vii = Some(func);
|
emfuncs.dyn_call_vii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_viii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viii") {
|
||||||
emfuncs.dyn_call_viii = Some(func);
|
emfuncs.dyn_call_viii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_viiii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viiii") {
|
||||||
emfuncs.dyn_call_viiii = Some(func);
|
emfuncs.dyn_call_viiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_dii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_dii") {
|
||||||
emfuncs.dyn_call_dii = Some(func);
|
emfuncs.dyn_call_dii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_diiii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_diiii") {
|
||||||
emfuncs.dyn_call_diiii = Some(func);
|
emfuncs.dyn_call_diiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_iiiii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_iiiii") {
|
||||||
emfuncs.dyn_call_iiiii = Some(func);
|
emfuncs.dyn_call_iiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_iiiiii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_iiiiii") {
|
||||||
emfuncs.dyn_call_iiiiii = Some(func);
|
emfuncs.dyn_call_iiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_iiiiiii") {
|
||||||
.exports
|
|
||||||
.get_native_function(&ctx, "dynCall_iiiiiii")
|
|
||||||
{
|
|
||||||
emfuncs.dyn_call_iiiiiii = Some(func);
|
emfuncs.dyn_call_iiiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_iiiiiiii")
|
.get_typed_function(&ctx, "dynCall_iiiiiiii")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_iiiiiiii = Some(func);
|
emfuncs.dyn_call_iiiiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_iiiiiiiii")
|
.get_typed_function(&ctx, "dynCall_iiiiiiiii")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_iiiiiiiii = Some(func);
|
emfuncs.dyn_call_iiiiiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_iiiiiiiiii")
|
.get_typed_function(&ctx, "dynCall_iiiiiiiiii")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_iiiiiiiiii = Some(func);
|
emfuncs.dyn_call_iiiiiiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_iiiiiiiiiii")
|
.get_typed_function(&ctx, "dynCall_iiiiiiiiiii")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_iiiiiiiiiii = Some(func);
|
emfuncs.dyn_call_iiiiiiiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_vd") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_vd") {
|
||||||
emfuncs.dyn_call_vd = Some(func);
|
emfuncs.dyn_call_vd = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_viiiii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viiiii") {
|
||||||
emfuncs.dyn_call_viiiii = Some(func);
|
emfuncs.dyn_call_viiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viiiiii") {
|
||||||
.exports
|
|
||||||
.get_native_function(&ctx, "dynCall_viiiiii")
|
|
||||||
{
|
|
||||||
emfuncs.dyn_call_viiiiii = Some(func);
|
emfuncs.dyn_call_viiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_viiiiiii")
|
.get_typed_function(&ctx, "dynCall_viiiiiii")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_viiiiiii = Some(func);
|
emfuncs.dyn_call_viiiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_viiiiiiii")
|
.get_typed_function(&ctx, "dynCall_viiiiiiii")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_viiiiiiii = Some(func);
|
emfuncs.dyn_call_viiiiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_viiiiiiiii")
|
.get_typed_function(&ctx, "dynCall_viiiiiiiii")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_viiiiiiiii = Some(func);
|
emfuncs.dyn_call_viiiiiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_viiiiiiiiii")
|
.get_typed_function(&ctx, "dynCall_viiiiiiiiii")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_viiiiiiiiii = Some(func);
|
emfuncs.dyn_call_viiiiiiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_iij") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_iij") {
|
||||||
emfuncs.dyn_call_iij = Some(func);
|
emfuncs.dyn_call_iij = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_iji") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_iji") {
|
||||||
emfuncs.dyn_call_iji = Some(func);
|
emfuncs.dyn_call_iji = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_iiji") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_iiji") {
|
||||||
emfuncs.dyn_call_iiji = Some(func);
|
emfuncs.dyn_call_iiji = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_iiijj") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_iiijj") {
|
||||||
emfuncs.dyn_call_iiijj = Some(func);
|
emfuncs.dyn_call_iiijj = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_j") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_j") {
|
||||||
emfuncs.dyn_call_j = Some(func);
|
emfuncs.dyn_call_j = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_ji") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_ji") {
|
||||||
emfuncs.dyn_call_ji = Some(func);
|
emfuncs.dyn_call_ji = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_jii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_jii") {
|
||||||
emfuncs.dyn_call_jii = Some(func);
|
emfuncs.dyn_call_jii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_jij") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_jij") {
|
||||||
emfuncs.dyn_call_jij = Some(func);
|
emfuncs.dyn_call_jij = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_jjj") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_jjj") {
|
||||||
emfuncs.dyn_call_jjj = Some(func);
|
emfuncs.dyn_call_jjj = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_viiij") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viiij") {
|
||||||
emfuncs.dyn_call_viiij = Some(func);
|
emfuncs.dyn_call_viiij = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_viiijiiii")
|
.get_typed_function(&ctx, "dynCall_viiijiiii")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_viiijiiii = Some(func);
|
emfuncs.dyn_call_viiijiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_viiijiiiiii")
|
.get_typed_function(&ctx, "dynCall_viiijiiiiii")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_viiijiiiiii = Some(func);
|
emfuncs.dyn_call_viiijiiiiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_viij") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viij") {
|
||||||
emfuncs.dyn_call_viij = Some(func);
|
emfuncs.dyn_call_viij = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_viiji") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viiji") {
|
||||||
emfuncs.dyn_call_viiji = Some(func);
|
emfuncs.dyn_call_viiji = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viijiii") {
|
||||||
.exports
|
|
||||||
.get_native_function(&ctx, "dynCall_viijiii")
|
|
||||||
{
|
|
||||||
emfuncs.dyn_call_viijiii = Some(func);
|
emfuncs.dyn_call_viijiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_viijj") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viijj") {
|
||||||
emfuncs.dyn_call_viijj = Some(func);
|
emfuncs.dyn_call_viijj = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_vj") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_vj") {
|
||||||
emfuncs.dyn_call_vj = Some(func);
|
emfuncs.dyn_call_vj = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_vjji") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_vjji") {
|
||||||
emfuncs.dyn_call_vjji = Some(func);
|
emfuncs.dyn_call_vjji = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_vij") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_vij") {
|
||||||
emfuncs.dyn_call_vij = Some(func);
|
emfuncs.dyn_call_vij = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_viji") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viji") {
|
||||||
emfuncs.dyn_call_viji = Some(func);
|
emfuncs.dyn_call_viji = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_vijiii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_vijiii") {
|
||||||
emfuncs.dyn_call_vijiii = Some(func);
|
emfuncs.dyn_call_vijiii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_vijj") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_vijj") {
|
||||||
emfuncs.dyn_call_vijj = Some(func);
|
emfuncs.dyn_call_vijj = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_viid") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viid") {
|
||||||
emfuncs.dyn_call_viid = Some(func);
|
emfuncs.dyn_call_viid = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_vidd") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_vidd") {
|
||||||
emfuncs.dyn_call_vidd = Some(func);
|
emfuncs.dyn_call_vidd = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "dynCall_viidii") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "dynCall_viidii") {
|
||||||
emfuncs.dyn_call_viidii = Some(func);
|
emfuncs.dyn_call_viidii = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance
|
if let Ok(func) = instance
|
||||||
.exports
|
.exports
|
||||||
.get_native_function(&ctx, "dynCall_viidddddddd")
|
.get_typed_function(&ctx, "dynCall_viidddddddd")
|
||||||
{
|
{
|
||||||
emfuncs.dyn_call_viidddddddd = Some(func);
|
emfuncs.dyn_call_viidddddddd = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "stackSave") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "stackSave") {
|
||||||
emfuncs.stack_save = Some(func);
|
emfuncs.stack_save = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "stackRestore") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "stackRestore") {
|
||||||
emfuncs.stack_restore = Some(func);
|
emfuncs.stack_restore = Some(func);
|
||||||
}
|
}
|
||||||
if let Ok(func) = instance.exports.get_native_function(&ctx, "setThrew") {
|
if let Ok(func) = instance.exports.get_typed_function(&ctx, "setThrew") {
|
||||||
emfuncs.set_threw = Some(func);
|
emfuncs.set_threw = Some(func);
|
||||||
}
|
}
|
||||||
ctx.data_mut().set_functions(emfuncs);
|
ctx.data_mut().set_functions(emfuncs);
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ fn dynamic_function_with_env_wasmer_env_init_works(config: crate::Config) -> Res
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
let f: TypedFunction<(), ()> = instance.exports.get_native_function("main")?;
|
let f: TypedFunction<(), ()> = instance.exports.get_typed_function("main")?;
|
||||||
f.call()?;
|
f.call()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -381,12 +381,12 @@ fn multi_use_host_fn_manages_memory_correctly(config: crate::Config) -> Result<(
|
|||||||
let instance1 = Instance::new(&module, &imports)?;
|
let instance1 = Instance::new(&module, &imports)?;
|
||||||
let instance2 = Instance::new(&module, &imports)?;
|
let instance2 = Instance::new(&module, &imports)?;
|
||||||
{
|
{
|
||||||
let f1: TypedFunction<(), ()> = instance1.exports.get_native_function("main")?;
|
let f1: TypedFunction<(), ()> = instance1.exports.get_typed_function("main")?;
|
||||||
f1.call()?;
|
f1.call()?;
|
||||||
}
|
}
|
||||||
drop(instance1);
|
drop(instance1);
|
||||||
{
|
{
|
||||||
let f2: TypedFunction<(), ()> = instance2.exports.get_native_function("main")?;
|
let f2: TypedFunction<(), ()> = instance2.exports.get_typed_function("main")?;
|
||||||
f2.call()?;
|
f2.call()?;
|
||||||
}
|
}
|
||||||
drop(instance2);
|
drop(instance2);
|
||||||
@@ -425,8 +425,8 @@ fn instance_local_memory_lifetime(config: crate::Config) -> Result<()> {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
let instance = Instance::new(&module, &imports)?;
|
let instance = Instance::new(&module, &imports)?;
|
||||||
let set_at: TypedFunction<(i32, i32), ()> = instance.exports.get_native_function("set_at")?;
|
let set_at: TypedFunction<(i32, i32), ()> = instance.exports.get_typed_function("set_at")?;
|
||||||
let get_at: TypedFunction<i32, i32> = instance.exports.get_native_function("get_at")?;
|
let get_at: TypedFunction<i32, i32> = instance.exports.get_typed_function("get_at")?;
|
||||||
set_at.call(200, 123)?;
|
set_at.call(200, 123)?;
|
||||||
assert_eq!(get_at.call(200)?, 123);
|
assert_eq!(get_at.call(200)?, 123);
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ fn run_add_with_limit(mut config: crate::Config, limit: u64) -> Result<()> {
|
|||||||
|
|
||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("add")?;
|
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("add")?;
|
||||||
f.call(4, 6)?;
|
f.call(4, 6)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ fn run_loop(mut config: crate::Config, limit: u64, iter_count: i32) -> Result<()
|
|||||||
|
|
||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
let f: TypedFunction<i32, ()> = instance.exports.get_native_function("test")?;
|
let f: TypedFunction<i32, ()> = instance.exports.get_typed_function("test")?;
|
||||||
f.call(iter_count)?;
|
f.call(iter_count)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ fn complex_loop(mut config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("add_to")?;
|
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("add_to")?;
|
||||||
|
|
||||||
// FIXME: Since now a metering error is signaled with an `unreachable`, it is impossible to verify
|
// FIXME: Since now a metering error is signaled with an `unreachable`, it is impossible to verify
|
||||||
// the error type. Fix this later.
|
// the error type. Fix this later.
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ fn middleware_basic(mut config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("add")?;
|
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("add")?;
|
||||||
let result = f.call(4, 6)?;
|
let result = f.call(4, 6)?;
|
||||||
assert_eq!(result, 24);
|
assert_eq!(result, 24);
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -127,7 +127,7 @@ fn middleware_one_to_multi(mut config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("add")?;
|
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("add")?;
|
||||||
let result = f.call(4, 6)?;
|
let result = f.call(4, 6)?;
|
||||||
assert_eq!(result, 25);
|
assert_eq!(result, 25);
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -151,7 +151,7 @@ fn middleware_multi_to_one(mut config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("testfunc")?;
|
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("testfunc")?;
|
||||||
let result = f.call(10, 20)?;
|
let result = f.call(10, 20)?;
|
||||||
assert_eq!(result, 10);
|
assert_eq!(result, 10);
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -175,7 +175,7 @@ fn middleware_chain_order_1(mut config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("add")?;
|
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("add")?;
|
||||||
let result = f.call(4, 6)?;
|
let result = f.call(4, 6)?;
|
||||||
assert_eq!(result, 24);
|
assert_eq!(result, 24);
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -199,7 +199,7 @@ fn middleware_chain_order_2(mut config: crate::Config) -> Result<()> {
|
|||||||
|
|
||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("add")?;
|
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("add")?;
|
||||||
let result = f.call(4, 6)?;
|
let result = f.call(4, 6)?;
|
||||||
assert_eq!(result, 48);
|
assert_eq!(result, 48);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ fn native_function_works_for_wasm(config: crate::Config) -> anyhow::Result<()> {
|
|||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
{
|
{
|
||||||
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_native_function("add")?;
|
let f: TypedFunction<(i32, i32), i32> = instance.exports.get_typed_function("add")?;
|
||||||
let result = f.call(4, 6)?;
|
let result = f.call(4, 6)?;
|
||||||
assert_eq!(result, 10);
|
assert_eq!(result, 10);
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ fn non_native_functions_and_closures_with_no_env_work(config: crate::Config) ->
|
|||||||
let instance = Instance::new(&module, &import_object)?;
|
let instance = Instance::new(&module, &import_object)?;
|
||||||
|
|
||||||
let test: TypedFunction<(i32, i32, i32, i32, i32), i32> =
|
let test: TypedFunction<(i32, i32, i32, i32, i32), i32> =
|
||||||
instance.exports.get_native_function("test")?;
|
instance.exports.get_typed_function("test")?;
|
||||||
|
|
||||||
let result = test.call(2, 3, 4, 5, 6)?;
|
let result = test.call(2, 3, 4, 5, 6)?;
|
||||||
let manually_computed_result = 6 * (5 * (4 * (3 * 2 * 20) * 10 * 20)) * 10;
|
let manually_computed_result = 6 * (5 * (4 * (3 * 2 * 20) * 10 * 20)) * 10;
|
||||||
|
|||||||
Reference in New Issue
Block a user