roblox_emulator: use a type alias to minimize errors
This commit is contained in:
parent
f0d4915fba
commit
03b16db10a
lib/roblox_emulator/src
@ -26,6 +26,7 @@ impl Services{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type LuaAppData=&'static mut WeakDom;
|
||||||
pub struct Context{
|
pub struct Context{
|
||||||
pub(crate)dom:WeakDom,
|
pub(crate)dom:WeakDom,
|
||||||
pub(crate)services:Services,
|
pub(crate)services:Services,
|
||||||
|
@ -37,7 +37,7 @@ pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table)->Result<(),mlua::Error>{
|
|||||||
|
|
||||||
// LMAO look at this function!
|
// LMAO look at this function!
|
||||||
pub fn dom_mut<T>(lua:&mlua::Lua,mut f:impl FnMut(&mut WeakDom)->mlua::Result<T>)->mlua::Result<T>{
|
pub fn dom_mut<T>(lua:&mlua::Lua,mut f:impl FnMut(&mut WeakDom)->mlua::Result<T>)->mlua::Result<T>{
|
||||||
let mut dom=lua.app_data_mut::<&'static mut WeakDom>().ok_or_else(||mlua::Error::runtime("DataModel missing"))?;
|
let mut dom=lua.app_data_mut::<crate::context::LuaAppData>().ok_or_else(||mlua::Error::runtime("DataModel missing"))?;
|
||||||
f(*dom)
|
f(*dom)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ impl Runner{
|
|||||||
globals.set("workspace",super::instance::Instance::new(context.services.workspace)).map_err(Error::RustLua)?;
|
globals.set("workspace",super::instance::Instance::new(context.services.workspace)).map_err(Error::RustLua)?;
|
||||||
}
|
}
|
||||||
//this makes set_app_data shut up about the lifetime
|
//this makes set_app_data shut up about the lifetime
|
||||||
self.lua.set_app_data::<&'static mut rbx_dom_weak::WeakDom>(unsafe{core::mem::transmute(&mut context.dom)});
|
self.lua.set_app_data::<crate::context::LuaAppData>(unsafe{core::mem::transmute(&mut context.dom)});
|
||||||
#[cfg(feature="run-service")]
|
#[cfg(feature="run-service")]
|
||||||
self.lua.set_app_data::<crate::scheduler::Scheduler>(crate::scheduler::Scheduler::default());
|
self.lua.set_app_data::<crate::scheduler::Scheduler>(crate::scheduler::Scheduler::default());
|
||||||
Ok(Runnable{
|
Ok(Runnable{
|
||||||
@ -77,7 +77,7 @@ pub struct Runnable<'a>{
|
|||||||
}
|
}
|
||||||
impl Runnable<'_>{
|
impl Runnable<'_>{
|
||||||
pub fn drop_context(self)->Runner{
|
pub fn drop_context(self)->Runner{
|
||||||
self.lua.remove_app_data::<&'static mut rbx_dom_weak::WeakDom>();
|
self.lua.remove_app_data::<crate::context::LuaAppData>();
|
||||||
#[cfg(feature="run-service")]
|
#[cfg(feature="run-service")]
|
||||||
self.lua.remove_app_data::<crate::scheduler::Scheduler>();
|
self.lua.remove_app_data::<crate::scheduler::Scheduler>();
|
||||||
Runner{
|
Runner{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user