use crate::defines::LevelInt; use crate::ffi::{BorrowedPtr, ExternPointer, OwnedPtr}; use crate::static_data::{LearnableMoves, LearnableMovesImpl}; use std::ffi::{c_char, CStr}; use std::ptr::drop_in_place; /// Instantiates a new Learnable Moves. #[no_mangle] extern "C" fn learnable_moves_new(max_level: LevelInt) -> OwnedPtr> { Box::into_raw(Box::new(Box::new(LearnableMovesImpl::new(max_level)))) } /// drops a learnablemoves struct. #[no_mangle] unsafe extern "C" fn learnable_moves_drop(ptr: OwnedPtr>) { drop_in_place(ptr) } /// Adds a new level move the Pokemon can learn. #[no_mangle] unsafe extern "C" fn learnable_moves_add_level_move( mut ptr: ExternPointer>, level: LevelInt, move_name: BorrowedPtr, ) { ptr.as_mut().add_level_move(level, &CStr::from_ptr(move_name).into()) }