2022-10-08 11:15:04 +00:00
|
|
|
use crate::ffi::{ExternPointer, IdentifiablePointer, OwnedPtr};
|
2022-10-01 13:40:15 +00:00
|
|
|
use crate::static_data::{
|
|
|
|
AbilityLibrary, GrowthRateLibrary, ItemLibrary, LibrarySettings, MoveLibrary, NatureLibrary, SpeciesLibrary,
|
|
|
|
StaticData, TypeLibrary,
|
|
|
|
};
|
|
|
|
use std::ptr::drop_in_place;
|
|
|
|
|
|
|
|
#[no_mangle]
|
2022-10-08 11:15:04 +00:00
|
|
|
unsafe extern "C" fn static_data_new(settings: OwnedPtr<LibrarySettings>) -> IdentifiablePointer<StaticData> {
|
|
|
|
Box::new(StaticData::new(*Box::from_raw(settings))).into()
|
2022-10-01 13:40:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
unsafe extern "C" fn static_data_drop(ptr: OwnedPtr<StaticData>) {
|
|
|
|
drop_in_place(ptr)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2022-10-08 11:15:04 +00:00
|
|
|
unsafe extern "C" fn static_data_settings(data: ExternPointer<StaticData>) -> IdentifiablePointer<LibrarySettings> {
|
|
|
|
(data.as_mut().settings() as *const LibrarySettings).into()
|
2022-10-01 13:40:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2022-10-08 11:15:04 +00:00
|
|
|
unsafe extern "C" fn static_data_species(data: ExternPointer<StaticData>) -> IdentifiablePointer<SpeciesLibrary> {
|
|
|
|
(data.as_mut().species_mut() as *const SpeciesLibrary).into()
|
2022-10-01 13:40:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2022-10-08 11:15:04 +00:00
|
|
|
unsafe extern "C" fn static_data_moves(data: ExternPointer<StaticData>) -> IdentifiablePointer<MoveLibrary> {
|
|
|
|
(data.as_mut().moves_mut() as *const MoveLibrary).into()
|
2022-10-01 13:40:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2022-10-08 11:15:04 +00:00
|
|
|
unsafe extern "C" fn static_data_items(data: ExternPointer<StaticData>) -> IdentifiablePointer<ItemLibrary> {
|
|
|
|
(data.as_mut().items_mut() as *const ItemLibrary).into()
|
2022-10-01 13:40:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2022-10-08 11:15:04 +00:00
|
|
|
unsafe extern "C" fn static_data_growth_rates(
|
|
|
|
data: ExternPointer<StaticData>,
|
|
|
|
) -> IdentifiablePointer<GrowthRateLibrary> {
|
|
|
|
(data.as_mut().growth_rates_mut() as *const GrowthRateLibrary).into()
|
2022-10-01 13:40:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2022-10-08 11:15:04 +00:00
|
|
|
unsafe extern "C" fn static_data_types(data: ExternPointer<StaticData>) -> IdentifiablePointer<TypeLibrary> {
|
|
|
|
(data.as_mut().types_mut() as *const TypeLibrary).into()
|
2022-10-01 13:40:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2022-10-08 11:15:04 +00:00
|
|
|
unsafe extern "C" fn static_data_natures(data: ExternPointer<StaticData>) -> IdentifiablePointer<NatureLibrary> {
|
|
|
|
(data.as_mut().natures_mut() as *const NatureLibrary).into()
|
2022-10-01 13:40:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2022-10-08 11:15:04 +00:00
|
|
|
unsafe extern "C" fn static_data_abilities(data: ExternPointer<StaticData>) -> IdentifiablePointer<AbilityLibrary> {
|
|
|
|
(data.as_mut().abilities_mut() as *const AbilityLibrary).into()
|
2022-10-01 13:40:15 +00:00
|
|
|
}
|