From 136b3605909d2a3669ab3854996663c2acb63cb2 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 5 Oct 2024 11:45:10 -0700 Subject: [PATCH] rename dom function to avoid confusion with dom variable --- src/runner/instance.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/runner/instance.rs b/src/runner/instance.rs index a850ac1..3489a3f 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -5,7 +5,7 @@ use rbx_dom_weak::{InstanceBuilder,WeakDom}; use super::vector3::Vector3; // LMAO look at this function! -fn dom(lua:&mlua::Lua,mut f:impl FnMut(&mut WeakDom)->mlua::Result)->mlua::Result{ +fn dom_mut(lua:&mlua::Lua,mut f:impl FnMut(&mut WeakDom)->mlua::Result)->mlua::Result{ let mut dom=lua.app_data_mut::<&'static mut WeakDom>().ok_or(mlua::Error::runtime("DataModel missing"))?; f(&mut *dom) } @@ -126,26 +126,26 @@ class_composition!(Instance,(Instance)); impl Instance{ fn composition_add_fields<'lua,T:Referent,F:mlua::UserDataFields<'lua,T>>(fields:&mut F){ fields.add_field_method_get("Parent",|lua,this|{ - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let instance=this.get(dom)?; Ok(Instance::new(instance.parent())) }) }); fields.add_field_method_set("Parent",|lua,this,val:mlua::AnyUserData|{ let Dereferent(referent)=mlua::AnyUserDataExt::get(&val,"Referent")?; - dom(lua,|dom|{ + dom_mut(lua,|dom|{ dom.transfer_within(this.referent(),referent); Ok(()) }) }); fields.add_field_method_get("Name",|lua,this|{ - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let instance=this.get(dom)?; Ok(instance.name.clone()) }) }); fields.add_field_method_set("Name",|lua,this,val:mlua::String|{ - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let instance=this.get_mut(dom)?; //Why does this need to be cloned? instance.name=val.to_str()?.to_owned(); @@ -153,7 +153,7 @@ impl Instance{ }) }); fields.add_field_method_get("ClassName",|lua,this|{ - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let instance=this.get(dom)?; Ok(instance.class.clone()) }) @@ -161,7 +161,7 @@ impl Instance{ } fn composition_add_methods<'lua,T:Referent,M:mlua::UserDataMethods<'lua,T>>(methods:&mut M){ methods.add_method("GetChildren",|lua,this,_:()| - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let instance=this.get(dom)?; let children:Vec<_>=instance .children() @@ -174,7 +174,7 @@ impl Instance{ ); let ffc=|lua,this:&T,(name,search_descendants):(mlua::String,Option)|{ let name_str=name.to_str()?; - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let instance=this.get(dom)?; Ok( match search_descendants.unwrap_or(false){ @@ -191,7 +191,7 @@ impl Instance{ methods.add_method("WaitForChild",ffc); methods.add_method("FindFirstChildOfClass",|lua,this,(class,search_descendants):(mlua::String,Option)|{ let class_str=class.to_str()?; - dom(lua,|dom|{ + dom_mut(lua,|dom|{ Ok( match search_descendants.unwrap_or(false){ true=>find_first_descendant_of_class(dom,this.get(dom)?,class_str), @@ -204,7 +204,7 @@ impl Instance{ }) }); methods.add_method("GetDescendants",|lua,this,_:()| - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let children:Vec<_>=dom .descendants_of(this.referent()) .map(|instance| @@ -215,13 +215,13 @@ impl Instance{ }) ); methods.add_method("IsA",|lua,this,classname:mlua::String| - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let instance=this.get(dom)?; Ok(crate::context::class_is_a(instance.class.as_str(),classname.to_str()?)) }) ); methods.add_method("Destroy",|lua,this,()| - dom(lua,|dom|{ + dom_mut(lua,|dom|{ dom.destroy(this.referent()); Ok(()) }) @@ -229,7 +229,7 @@ impl Instance{ methods.add_meta_function(mlua::MetaMethod::Index,|lua,(this,index):(mlua::AnyUserData,mlua::String)|{ let index_str=index.to_str()?; let dereferent:Dereferent=mlua::AnyUserDataExt::get(&this,"Referent")?; - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let instance=dereferent.get(dom)?; match instance.properties.get(index_str){ Some(&rbx_types::Variant::CFrame(cf))=>return Ok(Into::::into(cf).into_lua(lua)), @@ -247,7 +247,7 @@ impl Instance{ }); methods.add_meta_function(mlua::MetaMethod::NewIndex,|lua,(this,index,value):(mlua::AnyUserData,mlua::String,mlua::Value)|{ let dereferent:Dereferent=mlua::AnyUserDataExt::get(&this,"Referent")?; - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let instance=dereferent.get_mut(dom)?; //println!("__newindex t={} i={index:?} v={value:?}",instance.name); let index_str=index.to_str()?; @@ -308,7 +308,7 @@ class_composition!(DataModel,(Instance,DataModel)); impl DataModel{ fn composition_add_fields<'lua,T:Referent,F:mlua::UserDataFields<'lua,T>>(fields:&mut F){ fields.add_field_method_get("workspace",|lua,this|{ - dom(lua,|dom|{ + dom_mut(lua,|dom|{ Ok(find_first_child_of_class(dom,this.get(dom)?,"Workspace") .map(|inst|Workspace::new(inst.referent())) ) @@ -320,7 +320,7 @@ impl DataModel{ } fn composition_add_methods<'lua,T,M:mlua::UserDataMethods<'lua,T>>(methods:&mut M){ methods.add_method("GetService",|lua,this,service:String| - dom(lua,|dom|{ + dom_mut(lua,|dom|{ match service.as_str(){ "Lighting"=>{ let referent=find_first_child_of_class(dom,dom.root(),"Lighting") @@ -342,7 +342,7 @@ class_composition!(Workspace,(Instance,Workspace)); impl Workspace{ fn composition_add_fields<'lua,T:Referent,F:mlua::UserDataFields<'lua,T>>(fields:&mut F){ fields.add_field_method_get("Terrain",|lua,this|{ - dom(lua,|dom|{ + dom_mut(lua,|dom|{ Ok(find_first_child_of_class(dom,this.get(dom)?,"Terrain") .map(|inst|Terrain::new(inst.referent())) ) @@ -359,7 +359,7 @@ class!(Script); class_composition!(Script,(Instance)); impl Script{ pub fn get_name_source(&self,lua:&mlua::Lua)->Result<(String,String),mlua::Error>{ - dom(lua,|dom|{ + dom_mut(lua,|dom|{ let instance=self.get(dom)?; let source=match instance.properties.get("Source"){ Some(rbx_dom_weak::types::Variant::String(s))=>s.clone(),