Work on FFI, fixes for learned_move::restore_uses
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use crate::dynamic_data::{LearnedMove, MoveLearnMethod};
|
||||
use crate::ffi::{ExternPointer, IdentifiablePointer};
|
||||
use crate::ffi::{ExternPointer, IdentifiablePointer, OwnedPtr};
|
||||
use crate::static_data::MoveData;
|
||||
use std::ptr::drop_in_place;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Instantiate a new learned move.
|
||||
@@ -12,6 +13,12 @@ extern "C" fn learned_move_new(
|
||||
Arc::new(LearnedMove::new(move_data.as_ref(), learn_method)).into()
|
||||
}
|
||||
|
||||
/// Drops a learned move.
|
||||
#[no_mangle]
|
||||
extern "C" fn learned_move_drop(learned_move: OwnedPtr<Arc<LearnedMove>>) {
|
||||
unsafe { drop_in_place(learned_move) }
|
||||
}
|
||||
|
||||
/// The immutable move information of the move.
|
||||
#[no_mangle]
|
||||
extern "C" fn learned_move_move_data(
|
||||
@@ -39,7 +46,7 @@ extern "C" fn learned_move_learn_method(learned_move: ExternPointer<Arc<LearnedM
|
||||
}
|
||||
|
||||
/// Try and reduce the PP by a certain amount. If the amount is higher than the current uses,
|
||||
/// return false. Otherwise, reduce the PP, and return true.
|
||||
/// return 0. Otherwise, reduce the PP, and return 1.
|
||||
#[no_mangle]
|
||||
extern "C" fn learned_move_try_use(learned_move: ExternPointer<Arc<LearnedMove>>, amount: u8) -> u8 {
|
||||
u8::from(learned_move.as_ref().try_use(amount))
|
||||
|
||||
Reference in New Issue
Block a user