Reworks static library initialiser
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-12-24 12:48:00 +01:00
parent 02e3d7ecc7
commit efdaf730e6
3 changed files with 107 additions and 46 deletions

View File

@@ -9,8 +9,24 @@ use std::ptr::drop_in_place;
#[no_mangle]
unsafe extern "C" fn static_data_new(
settings: OwnedPtr<Box<dyn LibrarySettings>>,
species: OwnedPtr<Box<dyn SpeciesLibrary>>,
moves: OwnedPtr<Box<dyn MoveLibrary>>,
items: OwnedPtr<Box<dyn ItemLibrary>>,
growth_rates: OwnedPtr<Box<dyn GrowthRateLibrary>>,
types: OwnedPtr<Box<dyn TypeLibrary>>,
natures: OwnedPtr<Box<dyn NatureLibrary>>,
abilities: OwnedPtr<Box<dyn AbilityLibrary>>,
) -> IdentifiablePointer<Box<dyn StaticData>> {
let b: Box<dyn StaticData> = Box::new(StaticDataImpl::new(*Box::from_raw(settings)));
let b: Box<dyn StaticData> = 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()
}