Compare commits

...

1 Commits

Author SHA1 Message Date
00b2edb2a1 the "raw pointers" solution 2024-09-20 14:02:08 -07:00
2 changed files with 4 additions and 4 deletions

View File

@ -26,8 +26,8 @@ impl Instance{
// LMAO look at this function! // LMAO look at this function!
fn dom<T>(lua:&mlua::Lua,mut f:impl FnMut(&mut WeakDom)->mlua::Result<T>)->mlua::Result<T>{ fn dom<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(mlua::Error::runtime("DataModel missing"))?; let dom=*lua.app_data_mut::<*mut WeakDom>().ok_or(mlua::Error::runtime("DataModel missing"))?;
f(&mut *dom) f(unsafe{&mut *dom})
} }
fn coerce_float(value:&mlua::Value)->Option<f32>{ fn coerce_float(value:&mlua::Value)->Option<f32>{

View File

@ -79,13 +79,13 @@ impl Runner{
pub fn run_script(&self,script:crate::script::Script,context:&mut Context)->Result<(),Error>{ pub fn run_script(&self,script:crate::script::Script,context:&mut Context)->Result<(),Error>{
let yoink=script.name_source(context); let yoink=script.name_source(context);
//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::<*mut rbx_dom_weak::WeakDom>(&mut context.dom);
let (name,source)=yoink.map_err(Error::Script)?; let (name,source)=yoink.map_err(Error::Script)?;
self.lua.globals().set("script",super::instance::Instance::from(script)).map_err(Error::Lua)?; self.lua.globals().set("script",super::instance::Instance::from(script)).map_err(Error::Lua)?;
self.lua.load(source) self.lua.load(source)
.set_name(name) .set_name(name)
.exec().map_err(Error::Lua)?; .exec().map_err(Error::Lua)?;
self.lua.remove_app_data::<&'static mut rbx_dom_weak::WeakDom>(); self.lua.remove_app_data::<*mut rbx_dom_weak::WeakDom>();
Ok(()) Ok(())
} }
} }