the "raw pointers" solution
This commit is contained in:
parent
aa0bee9f69
commit
00b2edb2a1
@ -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>{
|
||||||
|
@ -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(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user