PkmnLib_rs/src/ffi/dynamic_data/libraries/battle_stat_calculator.rs

19 lines
699 B
Rust

use crate::dynamic_data::{BattleStatCalculator, Gen7BattleStatCalculator};
use crate::ffi::{IdentifiablePointer, OwnedPtr};
use std::ptr::drop_in_place;
/// Creates a new Gen 7 battle stat calculator
#[no_mangle]
extern "C" fn gen_7_battle_stat_calculator_new() -> IdentifiablePointer<Box<dyn BattleStatCalculator>> {
let v: Box<dyn BattleStatCalculator> = Box::new(Gen7BattleStatCalculator::new());
let id = v.value_identifier();
let ptr = Box::into_raw(Box::new(v));
IdentifiablePointer::new(ptr, id)
}
/// Drops a battle stat calculator.
#[no_mangle]
extern "C" fn battle_stat_calculator_drop(ptr: OwnedPtr<Box<dyn BattleStatCalculator>>) {
unsafe { drop_in_place(ptr) };
}