This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::dynamic_data::{
|
||||
BattleStatCalculator, DamageLibrary, DynamicLibrary, DynamicLibraryImpl, MiscLibrary, ScriptResolver,
|
||||
};
|
||||
use crate::ffi::{IdentifiablePointer, OwnedPtr};
|
||||
use crate::ffi::{ExternPointer, IdentifiablePointer, OwnedPtr};
|
||||
use crate::static_data::StaticData;
|
||||
use std::ptr::drop_in_place;
|
||||
use std::sync::Arc;
|
||||
@@ -29,6 +29,40 @@ extern "C" fn dynamic_library_new(
|
||||
|
||||
/// Drops a dynamic library.
|
||||
#[no_mangle]
|
||||
extern "C" fn dynamic_library_drop(ptr: OwnedPtr<Arc<dyn StaticData>>) {
|
||||
extern "C" fn dynamic_library_drop(ptr: OwnedPtr<Arc<dyn DynamicLibrary>>) {
|
||||
unsafe { drop_in_place(ptr) };
|
||||
}
|
||||
|
||||
/// The static data is the immutable storage data for this library.
|
||||
#[no_mangle]
|
||||
extern "C" fn dynamic_library_get_static_data(
|
||||
ptr: ExternPointer<Arc<dyn DynamicLibrary>>,
|
||||
) -> IdentifiablePointer<Box<dyn StaticData>> {
|
||||
ptr.as_ref().static_data().into()
|
||||
}
|
||||
|
||||
/// The stat calculator deals with the calculation of flat and boosted stats, based on the
|
||||
/// Pokemons attributes.
|
||||
#[no_mangle]
|
||||
extern "C" fn dynamic_library_get_stat_calculator(
|
||||
ptr: ExternPointer<Arc<dyn DynamicLibrary>>,
|
||||
) -> IdentifiablePointer<Box<dyn BattleStatCalculator>> {
|
||||
ptr.as_ref().stat_calculator().into()
|
||||
}
|
||||
|
||||
/// The damage calculator deals with the calculation of things relating to damage.
|
||||
#[no_mangle]
|
||||
extern "C" fn dynamic_library_get_damage_calculator(
|
||||
ptr: ExternPointer<Arc<dyn DynamicLibrary>>,
|
||||
) -> IdentifiablePointer<Box<dyn DamageLibrary>> {
|
||||
ptr.as_ref().damage_calculator().into()
|
||||
}
|
||||
|
||||
/// The Misc Library holds minor functions that do not fall in any of the other libraries and
|
||||
/// calculators.
|
||||
#[no_mangle]
|
||||
extern "C" fn dynamic_library_get_misc_library(
|
||||
ptr: ExternPointer<Arc<dyn DynamicLibrary>>,
|
||||
) -> IdentifiablePointer<Box<dyn MiscLibrary>> {
|
||||
ptr.as_ref().misc_library().into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user