Fix strange new compile errors
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2023-04-21 09:07:26 +02:00
parent c0e4702e45
commit db88d31394
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 26 additions and 4 deletions

View File

@ -24,7 +24,6 @@
#![feature(unboxed_closures)]
#![feature(trait_upcasting)]
#![feature(lazy_cell)]
#![feature(is_some_and)]
//! PkmnLib
//! PkmnLib is a full featured implementation of Pokemon. while currently focused on implementing

View File

@ -13,7 +13,6 @@ use wasmer::FunctionEnvMut;
/// An Extern Ref allows us to pass objects to WASM without actually passing raw memory, or
/// requiring us to make copies. Instead, we pass a simple increment index, that we can then use
/// to find the relevant data.
#[derive(Copy, Clone)]
pub(crate) struct ExternRef<T: ?Sized> {
/// The lookup index we can use to find the data.
index: usize,
@ -21,6 +20,17 @@ pub(crate) struct ExternRef<T: ?Sized> {
_phantom: PhantomData<T>,
}
impl<T: ?Sized> Copy for ExternRef<T> {}
impl<T: ?Sized> Clone for ExternRef<T> {
fn clone(&self) -> Self {
Self {
index: self.index,
_phantom: Default::default(),
}
}
}
impl<T: ValueIdentifiable + ?Sized> ExternRef<T> {
/// Instantiates a new ExternRef for a bit of data. If we already have made an Extern Ref for
/// this data and type, we use that instead.
@ -139,6 +149,16 @@ pub(crate) struct VecExternRef<T> {
_phantom: PhantomData<T>,
}
impl<T> Clone for VecExternRef<T> {
fn clone(&self) -> Self {
Self {
index: self.index,
size: self.size,
_phantom: Default::default(),
}
}
}
impl<T: 'static> VecExternRef<T> {
/// Instantiates a new VecExternRef for a given slice.
pub fn new(env: &WebAssemblyEnvironmentData, value: &Vec<T>) -> Self {

View File

@ -51,11 +51,14 @@ macro_rules! script_function_cache {
{
let read_lock = self.$name.read();
if let Some(f) = read_lock.as_ref() {
return Some(f.clone());
return Some(TypedFunction::clone(f));
}
}
self.[<initialize_ $name>](env);
self.$name.read().as_ref().cloned()
match self.$name.read().as_ref() {
Some(f) => Some(TypedFunction::clone(f)),
None => None,
}
}
}
)*