Make LearnableMoves a trait
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -23,7 +23,7 @@ unsafe extern "C" fn form_new(
|
||||
abilities_length: usize,
|
||||
hidden_abilities: *const BorrowedPtr<c_char>,
|
||||
hidden_abilities_length: usize,
|
||||
moves: OwnedPtr<LearnableMoves>,
|
||||
moves: OwnedPtr<Box<dyn LearnableMoves>>,
|
||||
flags: *const *const c_char,
|
||||
flags_length: usize,
|
||||
) -> IdentifiablePointer<Arc<Form>> {
|
||||
@@ -89,7 +89,11 @@ unsafe extern "C" fn form_base_stats(ptr: ExternPointer<Arc<Form>>) -> Identifia
|
||||
ffi_vec_stringkey_getters!(Form, abilities);
|
||||
ffi_vec_stringkey_getters!(Form, hidden_abilities);
|
||||
|
||||
ffi_arc_getter!(Form, moves, BorrowedPtr<LearnableMoves>);
|
||||
/// The moves a Pokemon with this form can learn.
|
||||
#[no_mangle]
|
||||
extern "C" fn form_moves(ptr: ExternPointer<Arc<Form>>) -> BorrowedPtr<Box<dyn LearnableMoves>> {
|
||||
ptr.as_ref().moves() as *const Box<dyn LearnableMoves>
|
||||
}
|
||||
|
||||
/// Check if the form has a specific flag set.
|
||||
#[no_mangle]
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
use crate::defines::LevelInt;
|
||||
use crate::ffi::{BorrowedPtr, ExternPointer, OwnedPtr};
|
||||
use crate::static_data::LearnableMoves;
|
||||
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() -> OwnedPtr<LearnableMoves> {
|
||||
Box::into_raw(Box::new(LearnableMoves::new()))
|
||||
extern "C" fn learnable_moves_new() -> OwnedPtr<Box<dyn LearnableMoves>> {
|
||||
Box::into_raw(Box::new(Box::new(LearnableMovesImpl::new())))
|
||||
}
|
||||
|
||||
/// drops a learnablemoves struct.
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn learnable_moves_drop(ptr: OwnedPtr<LearnableMoves>) {
|
||||
unsafe extern "C" fn learnable_moves_drop(ptr: OwnedPtr<Box<dyn LearnableMoves>>) {
|
||||
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<LearnableMoves>,
|
||||
mut ptr: ExternPointer<Box<dyn LearnableMoves>>,
|
||||
level: LevelInt,
|
||||
move_name: BorrowedPtr<c_char>,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user