use crate::ffi::{ExternPointer, IdentifiablePointer, OwnedPtr}; use crate::static_data::{ AbilityLibrary, GrowthRateLibrary, ItemLibrary, LibrarySettings, MoveLibrary, NatureLibrary, SpeciesLibrary, StaticData, StaticDataImpl, TypeLibrary, }; use std::ptr::drop_in_place; /// Instantiates a new data collection. #[no_mangle] unsafe extern "C" fn static_data_new( settings: OwnedPtr>, species: OwnedPtr>, moves: OwnedPtr>, items: OwnedPtr>, growth_rates: OwnedPtr>, types: OwnedPtr>, natures: OwnedPtr>, abilities: OwnedPtr>, ) -> IdentifiablePointer> { let b: Box = Box::new(StaticDataImpl::new( *Box::from_raw(settings), *Box::from_raw(species), *Box::from_raw(moves), *Box::from_raw(items), *Box::from_raw(growth_rates), *Box::from_raw(types), *Box::from_raw(natures), *Box::from_raw(abilities), )); b.into() } /// Drop a static data. #[no_mangle] unsafe extern "C" fn static_data_drop(ptr: OwnedPtr>) { drop_in_place(ptr) } /// Several misc settings for the library. #[no_mangle] unsafe extern "C" fn static_data_settings( mut data: ExternPointer>, ) -> IdentifiablePointer> { data.as_mut().settings().into() } /// All data for Pokemon species. #[no_mangle] unsafe extern "C" fn static_data_species( mut data: ExternPointer>, ) -> IdentifiablePointer> { data.as_mut().species().into() } /// All data for the moves. #[no_mangle] unsafe extern "C" fn static_data_moves( mut data: ExternPointer>, ) -> IdentifiablePointer> { data.as_mut().moves().into() } /// All data for the items. #[no_mangle] unsafe extern "C" fn static_data_items( mut data: ExternPointer>, ) -> IdentifiablePointer> { (data.as_mut().items()).into() } /// All data for growth rates. #[no_mangle] unsafe extern "C" fn static_data_growth_rates( mut data: ExternPointer>, ) -> IdentifiablePointer> { data.as_mut().growth_rates().into() } /// All data related to types and type effectiveness. #[no_mangle] unsafe extern "C" fn static_data_types( mut data: ExternPointer>, ) -> IdentifiablePointer> { data.as_mut().types().into() } /// All data related to natures. #[no_mangle] unsafe extern "C" fn static_data_natures( data: ExternPointer>, ) -> IdentifiablePointer> { data.as_ref().natures().into() } /// All data related to abilities. #[no_mangle] unsafe extern "C" fn static_data_abilities( mut data: ExternPointer>, ) -> IdentifiablePointer> { (data.as_mut().abilities()).into() }