2022-07-24 07:25:37 +00:00
|
|
|
pub(crate) mod cacheable;
|
|
|
|
pub(crate) mod cached_value;
|
|
|
|
pub mod capabilities;
|
|
|
|
pub mod extern_ref;
|
|
|
|
pub mod ffi_array;
|
|
|
|
pub mod script;
|
2022-08-14 11:37:17 +00:00
|
|
|
pub(crate) mod temporary;
|
2022-07-24 07:25:37 +00:00
|
|
|
|
|
|
|
pub use capabilities::*;
|
|
|
|
|
|
|
|
pub(crate) use cacheable::Cacheable;
|
|
|
|
pub use script::Script;
|
|
|
|
|
|
|
|
#[repr(u8)]
|
|
|
|
pub enum ScriptCategory {
|
|
|
|
Move,
|
|
|
|
Ability,
|
|
|
|
Status,
|
|
|
|
Pokemon,
|
|
|
|
Battle,
|
2022-09-16 09:01:17 +00:00
|
|
|
Weather,
|
2022-07-24 07:25:37 +00:00
|
|
|
Side,
|
|
|
|
ItemBattleTrigger,
|
|
|
|
}
|
2022-08-14 11:37:17 +00:00
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! wasm_reference_getters {
|
|
|
|
(
|
|
|
|
$base_type:ty,
|
|
|
|
$(
|
|
|
|
$(#[$attr:meta])*
|
|
|
|
$v:vis fn $name:ident(&self) -> $type:ty;
|
|
|
|
)*
|
|
|
|
) => {
|
|
|
|
impl $base_type {
|
|
|
|
$(
|
|
|
|
$(#[$attr])*
|
|
|
|
$v fn $name(&self) -> $type {
|
|
|
|
paste::paste!{
|
|
|
|
unsafe{
|
|
|
|
[<$base_type:snake _get_ $name>](self.inner.reference).get_value().unwrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)*
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-08-17 16:05:38 +00:00
|
|
|
#[cfg(not(feature = "mock_data"))]
|
|
|
|
extern "wasm" {
|
2022-08-14 11:37:17 +00:00
|
|
|
$(
|
|
|
|
paste::paste!{
|
|
|
|
fn [<$base_type:snake _get_ $name>](r: ExternRef<$base_type>) -> ExternRef<$type>;
|
|
|
|
}
|
|
|
|
)*
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! wasm_optional_reference_getters {
|
|
|
|
(
|
|
|
|
$base_type:ty,
|
|
|
|
$(
|
|
|
|
$(#[$attr:meta])*
|
|
|
|
$v:vis fn $name:ident(&self) -> Option<$type:ty>;
|
|
|
|
)*
|
|
|
|
) => {
|
|
|
|
impl $base_type {
|
|
|
|
$(
|
|
|
|
$(#[$attr])*
|
|
|
|
$v fn $name(&self) -> Option<$type> {
|
|
|
|
paste::paste!{
|
|
|
|
unsafe{
|
2022-09-09 18:09:56 +00:00
|
|
|
[<$base_type:snake _get_ $name>](self.inner.reference).get_value()
|
2022-08-14 11:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)*
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-08-17 16:05:38 +00:00
|
|
|
#[cfg(not(feature = "mock_data"))]
|
|
|
|
extern "wasm" {
|
2022-08-14 11:37:17 +00:00
|
|
|
$(
|
|
|
|
paste::paste!{
|
2022-09-09 18:09:56 +00:00
|
|
|
fn [<$base_type:snake _get_ $name>](r: ExternRef<$base_type>) -> ExternRef<$type>;
|
2022-08-14 11:37:17 +00:00
|
|
|
}
|
|
|
|
)*
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! wasm_value_getters {
|
|
|
|
(
|
|
|
|
$base_type:ty,
|
|
|
|
$(
|
|
|
|
$(#[$attr:meta])*
|
|
|
|
$v:vis fn $name:ident(&self) -> $type:ty;
|
|
|
|
)*
|
|
|
|
) => {
|
2022-08-17 16:05:38 +00:00
|
|
|
#[cfg(not(feature = "mock_data"))]
|
2022-08-14 11:37:17 +00:00
|
|
|
impl $base_type {
|
|
|
|
$(
|
|
|
|
$(#[$attr])*
|
|
|
|
$v fn $name(&self) -> $type {
|
|
|
|
paste::paste!{
|
|
|
|
unsafe{
|
2022-08-17 16:05:38 +00:00
|
|
|
[<$base_type:snake _get_ $name>](self.inner.reference)
|
2022-08-14 11:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)*
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-08-17 16:05:38 +00:00
|
|
|
#[cfg(not(feature = "mock_data"))]
|
|
|
|
extern "wasm" {
|
2022-08-14 11:37:17 +00:00
|
|
|
$(
|
|
|
|
paste::paste!{
|
2022-08-17 16:05:38 +00:00
|
|
|
fn [<$base_type:snake _get_ $name>](r: ExternRef<$base_type>) -> $type;
|
2022-08-14 11:37:17 +00:00
|
|
|
}
|
|
|
|
)*
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|