Update to Wasmer 3.0 beta
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-08-27 14:14:58 +02:00
parent c5fb81c179
commit bd62c1ac62
14 changed files with 315 additions and 241 deletions

View File

@@ -2,13 +2,13 @@ use std::sync::Arc;
use parking_lot::RwLock;
use paste::paste;
use wasmer::NativeFunc;
use crate::dynamic_data::{DynamicLibrary, TurnChoice};
use crate::script_implementations::wasm::extern_ref::{ExternRef, VecExternRef};
use crate::script_implementations::wasm::script_resolver::WebAssemblyEnvironmentData;
use crate::static_data::EffectParameter;
use crate::StringKey;
use wasmer::TypedFunction;
/// A macro to generate the script function cache a bit easier.
macro_rules! script_function_cache {
@@ -21,7 +21,7 @@ macro_rules! script_function_cache {
#[allow(unused_parens)]
pub struct ScriptFunctionCache {
$(
$name: RwLock<Option<NativeFunc<(u32$(, $par_type)*), ()>>>,
$name: RwLock<Option<TypedFunction<(u32$(, $par_type)*), ()>>>,
)*
}
@@ -34,7 +34,7 @@ macro_rules! script_function_cache {
let exported = env.exported_functions();
let f = exported.get::<StringKey>(&stringify!([< script_ $name >]).into());
if let Some(f) = f {
let func: NativeFunc<(u32 $(,$par_type)*), ()> = f.native().unwrap();
let func: TypedFunction<(u32 $(,$par_type)*), ()> = f.typed(&env.store_ref()).unwrap();
let _ = self.$name.write().insert(func);
}
}
@@ -44,7 +44,7 @@ macro_rules! script_function_cache {
pub(crate) fn [<$name>](
&self,
env: &Arc<WebAssemblyEnvironmentData>,
) -> Option<NativeFunc<(u32 $(,$par_type)*), ()>> {
) -> Option<TypedFunction<(u32 $(,$par_type)*), ()>> {
{
let read_lock = self.$name.read();
if let Some(f) = read_lock.as_ref() {