Skip to content

Commit

Permalink
Rename wasm_instance_new()’s “traps” argument to “trap”.
Browse files Browse the repository at this point in the history
  • Loading branch information
FGasper committed Jul 17, 2021
1 parent e916643 commit fcbc174
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C
## **[Unreleased]**

### 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.

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions lib/c-api/examples/features.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ int main(int argc, const char* argv[]) {

printf("Instantiating module...\n");
wasm_extern_vec_t imports = WASM_EMPTY_VEC;
wasm_trap_t* traps = NULL;
wasm_instance_t* instance = wasm_instance_new(store, module, &imports,&traps);
wasm_trap_t* trap = NULL;
wasm_instance_t* instance = wasm_instance_new(store, module, &imports,&trap);

if (!instance) {
printf("> Error instantiating module!\n");
Expand Down
4 changes: 2 additions & 2 deletions lib/c-api/src/wasm_c_api/externals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ mod tests {
assert(module);

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);

wasm_extern_vec_t exports;
Expand Down
16 changes: 8 additions & 8 deletions lib/c-api/src/wasm_c_api/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct wasm_instance_t {
/// 2. Runtime errors that happen when running the module `start`
/// 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.
///
/// # Notes
Expand All @@ -41,7 +41,7 @@ pub unsafe extern "C" fn wasm_instance_new(
_store: Option<&wasm_store_t>,
module: Option<&wasm_module_t>,
imports: Option<&wasm_extern_vec_t>,
traps: *mut *mut wasm_trap_t,
trap: *mut *mut wasm_trap_t,
) -> Option<Box<wasm_instance_t>> {
let module = module?;
let imports = imports?;
Expand All @@ -67,8 +67,8 @@ pub unsafe extern "C" fn wasm_instance_new(
}

Err(InstantiationError::Start(runtime_error)) => {
let trap: Box<wasm_trap_t> = Box::new(runtime_error.into());
*traps = Box::into_raw(trap);
let this_trap: Box<wasm_trap_t> = Box::new(runtime_error.into());
*trap = Box::into_raw(this_trap);

return None;
}
Expand Down Expand Up @@ -124,9 +124,9 @@ pub unsafe extern "C" fn wasm_instance_delete(_instance: Option<Box<wasm_instanc
///
/// // Instantiate the module.
/// 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);
///
/// // Read the exports.
Expand Down Expand Up @@ -252,8 +252,8 @@ mod tests {
wasm_extern_vec_t imports = WASM_ARRAY_VEC(externs);

// Instantiate the module.
wasm_trap_t* traps = NULL;
wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &traps);
wasm_trap_t* trap = NULL;
wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &trap);

assert(instance);

Expand Down
4 changes: 2 additions & 2 deletions lib/c-api/src/wasm_c_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ pub mod externals;
///
/// // Instantiate the module.
/// 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);
///
/// // Now do something with the instance, like calling the
Expand Down
8 changes: 4 additions & 4 deletions lib/c-api/src/wasm_c_api/unstable/middlewares/metering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
//!
//! // Instantiate the module.
//! wasm_extern_vec_t imports = WASM_EMPTY_VEC;
//! wasm_trap_t* traps = NULL;
//! wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &traps);
//! wasm_trap_t* trap = NULL;
//! wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &trap);
//! assert(instance);
//!
//! // Here we go. At this step, we will get the `add_two` exported function, and
Expand Down Expand Up @@ -269,8 +269,8 @@ pub extern "C" fn wasmer_metering_points_are_exhausted(instance: &wasm_instance_
/// assert(module);
///
/// wasm_extern_vec_t imports = WASM_EMPTY_VEC;
/// wasm_trap_t* traps = NULL;
/// wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &traps);
/// wasm_trap_t* trap = NULL;
/// wasm_instance_t* instance = wasm_instance_new(store, module, &imports, &trap);
/// assert(instance);
///
/// // Read the number of points.
Expand Down

0 comments on commit fcbc174

Please sign in to comment.