FFI for dynamic libraries

This commit is contained in:
2022-10-14 10:33:19 +02:00
parent 41b40ef98e
commit a840605bf7
15 changed files with 192 additions and 16 deletions

View File

@@ -19,10 +19,12 @@ use crate::script_implementations::wasm::script_function_cache::ScriptFunctionCa
use crate::script_implementations::wasm::temp_wasm_allocator::{AllocatedObject, TempWasmAllocator};
use crate::script_implementations::wasm::WebAssemblyScriptCapabilities;
use crate::static_data::Item;
use crate::{PkmnResult, ScriptCategory, StringKey};
use crate::{PkmnResult, ScriptCategory, StringKey, ValueIdentifiable, ValueIdentifier};
/// A WebAssembly script resolver implements the dynamic scripts functionality with WebAssembly.
pub struct WebAssemblyScriptResolver {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,
/// The global state storage of WASM.
_store: *mut Store,
/// The WASM modules we have loaded.
@@ -63,6 +65,7 @@ impl WebAssemblyScriptResolver {
environment.self_arc.write().replace(Arc::downgrade(&environment));
let s = Self {
identifier: Default::default(),
_store: store_ptr,
modules: Default::default(),
instances: Default::default(),
@@ -163,6 +166,12 @@ impl WebAssemblyScriptResolver {
}
}
impl ValueIdentifiable for WebAssemblyScriptResolver {
fn value_identifier(&self) -> ValueIdentifier {
self.identifier
}
}
impl ScriptResolver for WebAssemblyScriptResolver {
fn load_script(
&self,