Major rework of extern ref system for WASM, fixes most possible panics in WASM handling
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
2023-06-22 15:43:41 +02:00
parent 6a2353df4c
commit 46195d3042
71 changed files with 2142 additions and 1488 deletions

View File

@@ -1,6 +1,7 @@
use crate::static_data::EffectParameter;
use crate::{StringKey, ValueIdentifiable, ValueIdentifier};
use std::fmt::Debug;
use std::sync::Arc;
/// An ability is a passive effect in battle that is attached to a Pokemon.
pub trait Ability: Debug + ValueIdentifiable {
@@ -9,7 +10,7 @@ pub trait Ability: Debug + ValueIdentifiable {
/// The name of the script effect of the ability.
fn effect(&self) -> &StringKey;
/// The parameters for the script effect of the ability.
fn parameters(&self) -> &Vec<EffectParameter>;
fn parameters(&self) -> &Vec<Arc<EffectParameter>>;
}
/// An ability is a passive effect in battle that is attached to a Pokemon.
@@ -22,12 +23,12 @@ pub struct AbilityImpl {
/// The name of the script effect of the ability.
effect: StringKey,
/// The parameters for the script effect of the ability.
parameters: Vec<EffectParameter>,
parameters: Vec<Arc<EffectParameter>>,
}
impl AbilityImpl {
/// Instantiates a new ability.
pub fn new(name: &StringKey, effect: &StringKey, parameters: Vec<EffectParameter>) -> Self {
pub fn new(name: &StringKey, effect: &StringKey, parameters: Vec<Arc<EffectParameter>>) -> Self {
Self {
identifier: Default::default(),
name: name.clone(),
@@ -47,7 +48,7 @@ impl Ability for AbilityImpl {
&self.effect
}
/// The parameters for the script effect of the ability.
fn parameters(&self) -> &Vec<EffectParameter> {
fn parameters(&self) -> &Vec<Arc<EffectParameter>> {
&self.parameters
}
}
@@ -81,7 +82,7 @@ pub(crate) mod tests {
impl Ability for Ability {
fn name(&self) -> &StringKey;
fn effect(&self) -> &StringKey;
fn parameters(&self) -> &Vec<EffectParameter>;
fn parameters(&self) -> &Vec<Arc<EffectParameter>>;
}
impl ValueIdentifiable for Ability {
fn value_identifier(&self) -> ValueIdentifier {