mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-13 05:48:45 +00:00
@@ -9,6 +9,8 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C
|
|||||||
## **[Unreleased]**
|
## **[Unreleased]**
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- [#2478](https://github.com/wasmerio/wasmer/pull/2478) Rename `traps` input to `wasm_instance_new()` to `trap`.
|
||||||
|
|
||||||
- [#2427](https://github.com/wasmerio/wasmer/pull/2427) Update `loupe` to 0.1.3.
|
- [#2427](https://github.com/wasmerio/wasmer/pull/2427) Update `loupe` to 0.1.3.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
printf("Instantiating module...\n");
|
printf("Instantiating module...\n");
|
||||||
wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
||||||
wasm_trap_t* traps = NULL;
|
wasm_trap_t* trap = NULL;
|
||||||
wasm_instance_t* instance = wasm_instance_new(store, module, &imports,&traps);
|
wasm_instance_t* instance = wasm_instance_new(store, module, &imports,&trap);
|
||||||
|
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
printf("> Error instantiating module!\n");
|
printf("> Error instantiating module!\n");
|
||||||
@@ -67,7 +67,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
wasm_val_vec_t arguments_as_array = WASM_ARRAY_VEC(arguments);
|
wasm_val_vec_t arguments_as_array = WASM_ARRAY_VEC(arguments);
|
||||||
wasm_val_vec_t results_as_array = WASM_ARRAY_VEC(results);
|
wasm_val_vec_t results_as_array = WASM_ARRAY_VEC(results);
|
||||||
|
|
||||||
wasm_trap_t* trap = wasm_func_call(swap, &arguments_as_array, &results_as_array);
|
trap = wasm_func_call(swap, &arguments_as_array, &results_as_array);
|
||||||
|
|
||||||
if (trap != NULL) {
|
if (trap != NULL) {
|
||||||
printf("> Failed to call `swap`.\n");
|
printf("> Failed to call `swap`.\n");
|
||||||
|
|||||||
4
lib/c-api/src/wasm_c_api/externals/mod.rs
vendored
4
lib/c-api/src/wasm_c_api/externals/mod.rs
vendored
@@ -275,9 +275,9 @@ mod tests {
|
|||||||
assert(module);
|
assert(module);
|
||||||
|
|
||||||
wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
||||||
wasm_trap_t* traps = NULL;
|
wasm_trap_t* trap = NULL;
|
||||||
|
|
||||||
wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &traps);
|
wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &trap);
|
||||||
assert(instance);
|
assert(instance);
|
||||||
|
|
||||||
wasm_extern_vec_t exports;
|
wasm_extern_vec_t exports;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ pub struct wasm_instance_t {
|
|||||||
/// 2. Runtime errors that happen when running the module `start`
|
/// 2. Runtime errors that happen when running the module `start`
|
||||||
/// function.
|
/// function.
|
||||||
///
|
///
|
||||||
/// Failures are stored in the `traps` argument; the program doesn't
|
/// The failure is stored in the `trap` argument; the program doesn't
|
||||||
/// panic.
|
/// panic.
|
||||||
///
|
///
|
||||||
/// # Notes
|
/// # Notes
|
||||||
@@ -41,7 +41,7 @@ pub unsafe extern "C" fn wasm_instance_new(
|
|||||||
_store: Option<&wasm_store_t>,
|
_store: Option<&wasm_store_t>,
|
||||||
module: Option<&wasm_module_t>,
|
module: Option<&wasm_module_t>,
|
||||||
imports: Option<&wasm_extern_vec_t>,
|
imports: Option<&wasm_extern_vec_t>,
|
||||||
traps: *mut *mut wasm_trap_t,
|
trap: *mut *mut wasm_trap_t,
|
||||||
) -> Option<Box<wasm_instance_t>> {
|
) -> Option<Box<wasm_instance_t>> {
|
||||||
let module = module?;
|
let module = module?;
|
||||||
let imports = imports?;
|
let imports = imports?;
|
||||||
@@ -67,8 +67,8 @@ pub unsafe extern "C" fn wasm_instance_new(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Err(InstantiationError::Start(runtime_error)) => {
|
Err(InstantiationError::Start(runtime_error)) => {
|
||||||
let trap: Box<wasm_trap_t> = Box::new(runtime_error.into());
|
let this_trap: Box<wasm_trap_t> = Box::new(runtime_error.into());
|
||||||
*traps = Box::into_raw(trap);
|
*trap = Box::into_raw(this_trap);
|
||||||
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@@ -124,9 +124,9 @@ pub unsafe extern "C" fn wasm_instance_delete(_instance: Option<Box<wasm_instanc
|
|||||||
///
|
///
|
||||||
/// // Instantiate the module.
|
/// // Instantiate the module.
|
||||||
/// wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
/// wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
||||||
/// wasm_trap_t* traps = NULL;
|
/// wasm_trap_t* trap = NULL;
|
||||||
///
|
///
|
||||||
/// wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &traps);
|
/// wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &trap);
|
||||||
/// assert(instance);
|
/// assert(instance);
|
||||||
///
|
///
|
||||||
/// // Read the exports.
|
/// // Read the exports.
|
||||||
@@ -252,8 +252,8 @@ mod tests {
|
|||||||
wasm_extern_vec_t imports = WASM_ARRAY_VEC(externs);
|
wasm_extern_vec_t imports = WASM_ARRAY_VEC(externs);
|
||||||
|
|
||||||
// Instantiate the module.
|
// Instantiate the module.
|
||||||
wasm_trap_t* traps = NULL;
|
wasm_trap_t* trap = NULL;
|
||||||
wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &traps);
|
wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &trap);
|
||||||
|
|
||||||
assert(instance);
|
assert(instance);
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ mod tests {
|
|||||||
wasm_val_vec_t arguments_as_array = WASM_ARRAY_VEC(arguments);
|
wasm_val_vec_t arguments_as_array = WASM_ARRAY_VEC(arguments);
|
||||||
wasm_val_vec_t results_as_array = WASM_ARRAY_VEC(results);
|
wasm_val_vec_t results_as_array = WASM_ARRAY_VEC(results);
|
||||||
|
|
||||||
wasm_trap_t* trap = wasm_func_call(run_function, &arguments_as_array, &results_as_array);
|
trap = wasm_func_call(run_function, &arguments_as_array, &results_as_array);
|
||||||
|
|
||||||
assert(trap == NULL);
|
assert(trap == NULL);
|
||||||
assert(results[0].of.i32 == 2);
|
assert(results[0].of.i32 == 2);
|
||||||
|
|||||||
@@ -102,9 +102,9 @@ pub mod externals;
|
|||||||
///
|
///
|
||||||
/// // Instantiate the module.
|
/// // Instantiate the module.
|
||||||
/// wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
/// wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
||||||
/// wasm_trap_t* traps = NULL;
|
/// wasm_trap_t* trap = NULL;
|
||||||
///
|
///
|
||||||
/// wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &traps);
|
/// wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &trap);
|
||||||
/// assert(instance);
|
/// assert(instance);
|
||||||
///
|
///
|
||||||
/// // Now do something with the instance, like calling the
|
/// // Now do something with the instance, like calling the
|
||||||
|
|||||||
@@ -66,8 +66,8 @@
|
|||||||
//!
|
//!
|
||||||
//! // Instantiate the module.
|
//! // Instantiate the module.
|
||||||
//! wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
//! wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
||||||
//! wasm_trap_t* traps = NULL;
|
//! wasm_trap_t* trap = NULL;
|
||||||
//! wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &traps);
|
//! wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &trap);
|
||||||
//! assert(instance);
|
//! assert(instance);
|
||||||
//!
|
//!
|
||||||
//! // Here we go. At this step, we will get the `add_two` exported function, and
|
//! // Here we go. At this step, we will get the `add_two` exported function, and
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
//!
|
//!
|
||||||
//! // Let's call `add_two` for the first time!
|
//! // Let's call `add_two` for the first time!
|
||||||
//! {
|
//! {
|
||||||
//! wasm_trap_t* trap = wasm_func_call(add_two, &arguments_as_array, &results_as_array);
|
//! trap = wasm_func_call(add_two, &arguments_as_array, &results_as_array);
|
||||||
//! assert(trap == NULL);
|
//! assert(trap == NULL);
|
||||||
//! assert(results[0].of.i32 == 42);
|
//! assert(results[0].of.i32 == 42);
|
||||||
//!
|
//!
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
//!
|
//!
|
||||||
//! // Let's call `add_two` for the second time!
|
//! // Let's call `add_two` for the second time!
|
||||||
//! {
|
//! {
|
||||||
//! wasm_trap_t* trap = wasm_func_call(add_two, &arguments_as_array, &results_as_array);
|
//! trap = wasm_func_call(add_two, &arguments_as_array, &results_as_array);
|
||||||
//! assert(trap == NULL);
|
//! assert(trap == NULL);
|
||||||
//! assert(results[0].of.i32 == 42);
|
//! assert(results[0].of.i32 == 42);
|
||||||
//!
|
//!
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
//!
|
//!
|
||||||
//! // Let's call `add_two` for the third time!
|
//! // Let's call `add_two` for the third time!
|
||||||
//! {
|
//! {
|
||||||
//! wasm_trap_t* trap = wasm_func_call(add_two, &arguments_as_array, &results_as_array);
|
//! trap = wasm_func_call(add_two, &arguments_as_array, &results_as_array);
|
||||||
//! // Oh, it failed!
|
//! // Oh, it failed!
|
||||||
//! assert(trap != NULL);
|
//! assert(trap != NULL);
|
||||||
//!
|
//!
|
||||||
@@ -269,8 +269,8 @@ pub extern "C" fn wasmer_metering_points_are_exhausted(instance: &wasm_instance_
|
|||||||
/// assert(module);
|
/// assert(module);
|
||||||
///
|
///
|
||||||
/// wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
/// wasm_extern_vec_t imports = WASM_EMPTY_VEC;
|
||||||
/// wasm_trap_t* traps = NULL;
|
/// wasm_trap_t* trap = NULL;
|
||||||
/// wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &traps);
|
/// wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &trap);
|
||||||
/// assert(instance);
|
/// assert(instance);
|
||||||
///
|
///
|
||||||
/// // Read the number of points.
|
/// // Read the number of points.
|
||||||
|
|||||||
Reference in New Issue
Block a user