26 lines
853 B
Rust
26 lines
853 B
Rust
use crate::defines::LevelInt;
|
|
use crate::ffi::ffi_handle::{FFIHandle, FromFFIHandle};
|
|
use crate::ffi::{FFIResult, NonOwnedPtrString};
|
|
use crate::static_data::{LearnableMoves, LearnableMovesImpl};
|
|
use std::ffi::CStr;
|
|
use std::sync::Arc;
|
|
|
|
/// Instantiates a new Learnable Moves.
|
|
#[no_mangle]
|
|
extern "C" fn learnable_moves_new(max_level: LevelInt) -> FFIHandle<Arc<dyn LearnableMoves>> {
|
|
let p: Arc<dyn LearnableMoves> = Arc::new(LearnableMovesImpl::new(max_level));
|
|
FFIHandle::get_handle(p.into())
|
|
}
|
|
|
|
/// Adds a new level move the Pokemon can learn.
|
|
#[no_mangle]
|
|
unsafe extern "C" fn learnable_moves_add_level_move(
|
|
ptr: FFIHandle<Arc<dyn LearnableMoves>>,
|
|
level: LevelInt,
|
|
move_name: NonOwnedPtrString,
|
|
) -> FFIResult<()> {
|
|
ptr.from_ffi_handle()
|
|
.add_level_move(level, &CStr::from_ptr(move_name).into())
|
|
.into()
|
|
}
|