From 9784abfd45473e44f565aa86b950456725a071e6 Mon Sep 17 00:00:00 2001 From: cat_or_not <41955154+catornot@users.noreply.github.com> Date: Tue, 23 Jan 2024 12:21:05 -0500 Subject: [PATCH] fix squirrel stuff + notes --- Cargo.toml | 1 - src/bindings/squirrelfunctions.rs | 2 +- src/high/engine_sync.rs | 2 ++ src/high/mod.rs | 4 ++-- src/high/squirrel.rs | 12 ++++++------ src/interfaces/external.rs | 2 ++ src/interfaces/manager.rs | 5 +++++ src/macros/entry.rs | 1 + 8 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index eab4fd4..30a9fda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,5 +25,4 @@ default-target = "x86_64-pc-windows-msvc" targets = ["x86_64-pc-windows-msvc"] [features] -default = [] async_engine = [] diff --git a/src/bindings/squirrelfunctions.rs b/src/bindings/squirrelfunctions.rs index 31f8847..2d90b24 100644 --- a/src/bindings/squirrelfunctions.rs +++ b/src/bindings/squirrelfunctions.rs @@ -28,7 +28,7 @@ offset_functions! { sq_raiseerror = sq_raiseerrorType where offset(0x8440); - sq_getstring = sq_getstringType where offset(0x5840); + sq_getstring = sq_getstringType where offset(0x60A0); sq_getinteger = sq_getintegerType where offset(0x60C0); sq_getfloat = sq_getfloatType where offset(0x60E0); sq_getbool = sq_getboolType where offset(0x6110); diff --git a/src/high/engine_sync.rs b/src/high/engine_sync.rs index 6fb1877..0e26b94 100644 --- a/src/high/engine_sync.rs +++ b/src/high/engine_sync.rs @@ -162,6 +162,8 @@ macro_rules! into_squirrel_args_impl{ )* } } +// TODO: add single parameter + into_squirrel_args_impl! { (T1: 0); (T1: 0, T2: 1); diff --git a/src/high/mod.rs b/src/high/mod.rs index ac7b581..bbb46d4 100644 --- a/src/high/mod.rs +++ b/src/high/mod.rs @@ -10,11 +10,11 @@ pub mod squirrel; pub mod squirrel_traits; pub mod vector; -#[cfg(feature = "async_engine ")] +#[cfg(feature = "async_engine")] pub mod engine_sync; #[doc(hidden)] -#[cfg(not(feature = "async_engine "))] +#[cfg(not(feature = "async_engine"))] pub mod engine_sync { #[doc(hidden)] #[inline(always)] diff --git a/src/high/squirrel.rs b/src/high/squirrel.rs index 4723d6c..a2bd7cd 100644 --- a/src/high/squirrel.rs +++ b/src/high/squirrel.rs @@ -43,16 +43,16 @@ impl CSquirrelVMHandle { ) -> Self { unsafe { match (context, is_being_dropped) { - (ScriptContext::SERVER, true) => { + (ScriptContext::SERVER, false) => { _ = SQVM_SERVER.get(token).replace(Some((*handle).sqvm)) } - (ScriptContext::SERVER, false) => _ = SQVM_SERVER.get(token).replace(None), - (ScriptContext::CLIENT, true) => { + (ScriptContext::SERVER, true) => _ = SQVM_SERVER.get(token).replace(None), + (ScriptContext::CLIENT, false) => { _ = SQVM_CLIENT.get(token).replace(Some((*handle).sqvm)) } - (ScriptContext::CLIENT, false) => _ = SQVM_CLIENT.get(token).replace(None), - (ScriptContext::UI, true) => _ = SQVM_UI.get(token).replace(Some((*handle).sqvm)), - (ScriptContext::UI, false) => _ = SQVM_UI.get(token).replace(None), + (ScriptContext::CLIENT, true) => _ = SQVM_CLIENT.get(token).replace(None), + (ScriptContext::UI, false) => _ = SQVM_UI.get(token).replace(Some((*handle).sqvm)), + (ScriptContext::UI, true) => _ = SQVM_UI.get(token).replace(None), } } Self { diff --git a/src/interfaces/external.rs b/src/interfaces/external.rs index df0b252..0914922 100644 --- a/src/interfaces/external.rs +++ b/src/interfaces/external.rs @@ -10,6 +10,8 @@ use windows::{ use crate::{bindings::plugin_abi::CreateInterface, mid::utils::try_cstring}; +// TODO: impl Sync and Send for interfaces since they are unsafe the reponsibility falls on the user to mamnage from where they are called and some are thread safe + #[macro_export] macro_rules! create_external_interface { { $struct_vis:vis $interface_name:ident + $mod_name:ident => {$($func_vis:vis fn $name:ident( $( $arg_name:ident : $arg:ty),*) -> $output:ty );*;}} => { diff --git a/src/interfaces/manager.rs b/src/interfaces/manager.rs index 2c86e7c..0d305ce 100644 --- a/src/interfaces/manager.rs +++ b/src/interfaces/manager.rs @@ -41,3 +41,8 @@ pub unsafe fn register_interface( UnsafeHandle::internal_new(Box::leak(Box::new(interface)) as *const _ as *const c_void), ); } + +// TODO: implement this +// pub unsafe fn get_local( + +// ) diff --git a/src/macros/entry.rs b/src/macros/entry.rs index 86dcc6c..5a20fc3 100644 --- a/src/macros/entry.rs +++ b/src/macros/entry.rs @@ -32,6 +32,7 @@ macro_rules! entry { pub(crate) use exports::PLUGIN; #[doc(hidden)] pub(crate) mod exports { + #![allow(non_snake_case)] use super::$plugin; use high::engine::EngineData;