A bunch more work on replacing every potential panic with results
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-04-16 19:57:21 +02:00
parent 1b8403ecda
commit 00d596d656
37 changed files with 526 additions and 300 deletions

View File

@@ -1,3 +1,10 @@
/// The WASM module handles loading dynamic scripts through WebAssembly.
#[cfg(feature = "wasm")]
// FIXME: allow these for now until we have a good result interface defined.
#[allow(clippy::unwrap_used)]
#[allow(clippy::expect_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::string_slice)]
#[allow(clippy::exit)]
#[allow(clippy::panic)]
pub mod wasm;

View File

@@ -78,7 +78,7 @@ register! {
let c_name = CStr::from_ptr(env.data().data().get_raw_pointer(name_ptr));
let script = side.value_func(&env).unwrap().add_volatile_script(&c_name.as_ref().into()).unwrap();
if let Some(script) = script {
let script = script.get_as::<WebAssemblyScript>();
let script = script.get_as::<WebAssemblyScript>().unwrap();
script.get_wasm_pointer()
} else {
0
@@ -101,7 +101,7 @@ register! {
if let Some(script) = script {
let script = side.add_volatile_script_with_script(script);
let s = script.as_ref().unwrap().as_ref().unwrap().get_as::<WebAssemblyScript>();
let s = script.as_ref().unwrap().as_ref().unwrap().get_as::<WebAssemblyScript>().unwrap();
s.get_wasm_pointer()
} else {
0
@@ -129,7 +129,7 @@ register! {
let c_name = CStr::from_ptr(env.data().data().get_raw_pointer(name_ptr));
let script = side.value_func(&env).unwrap().get_volatile_script(&c_name.as_ref().into());
if let Some(script) = script {
let script = script.get_as::<WebAssemblyScript>();
let script = script.get_as::<WebAssemblyScript>().unwrap();
script.get_wasm_pointer()
} else {
0
@@ -144,7 +144,7 @@ register! {
) {
unsafe {
let c_name = CStr::from_ptr(env.data().data().get_raw_pointer(name_ptr));
side.value_func(&env).unwrap().remove_volatile_script(&c_name.as_ref().into());
side.value_func(&env).unwrap().remove_volatile_script(&c_name.as_ref().into()).unwrap();
}
}

View File

@@ -413,7 +413,7 @@ register! {
let c_name = CStr::from_ptr(env.data().data().get_raw_pointer(name_ptr));
let script = pokemon.value_func(&env).unwrap().add_volatile_script(&c_name.as_ref().into()).unwrap();
if let Some(script) = script {
let script = script.get_as::<WebAssemblyScript>();
let script = script.get_as::<WebAssemblyScript>().unwrap();
script.get_wasm_pointer()
} else {
0
@@ -436,7 +436,7 @@ register! {
if let Some(script) = script {
let script = pokemon.add_volatile_script_with_script(script);
let s = script.as_ref().unwrap().as_ref().unwrap().get_as::<WebAssemblyScript>();
let s = script.as_ref().unwrap().as_ref().unwrap().get_as::<WebAssemblyScript>().unwrap();
s.get_wasm_pointer()
} else {
0
@@ -464,7 +464,7 @@ register! {
let c_name = CStr::from_ptr(env.data().data().get_raw_pointer(name_ptr));
let script = pokemon.value_func(&env).unwrap().get_volatile_script(&c_name.as_ref().into());
if let Some(script) = script {
let script = script.get_as::<WebAssemblyScript>();
let script = script.get_as::<WebAssemblyScript>().unwrap();
script.get_wasm_pointer()
} else {
0
@@ -479,7 +479,7 @@ register! {
) {
unsafe {
let c_name = CStr::from_ptr(env.data().data().get_raw_pointer(name_ptr));
pokemon.value_func(&env).unwrap().remove_volatile_script(&c_name.as_ref().into());
pokemon.value_func(&env).unwrap().remove_volatile_script(&c_name.as_ref().into()).unwrap();
}
}

View File

@@ -1,6 +1,3 @@
// allow these for now until we have a good result interface defined.
#[allow(clippy::unwrap_used)]
#[allow(clippy::expect_used)]
/// The export registry module deals with registering all functions we require in WebAssembly.
mod export_registry;
/// A hacky extern ref implementation to ensure the client does not do things it is not allowed to do.