sneak past type issues

This commit is contained in:
Quaternions 2024-10-03 19:14:58 -07:00
parent e67f0f0889
commit d272ac242b

View File

@ -33,6 +33,11 @@ fn get_full_name(dom:&rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance)->S
struct Dereferent(Ref);
impl mlua::UserData for Dereferent{}
type_from_lua_userdata!(Dereferent);
impl Referent for Dereferent{
fn referent(&self)->Ref{
self.0
}
}
trait Referent{
fn referent(&self)->Ref;
@ -152,10 +157,11 @@ impl Instance{
Ok(crate::context::class_is_a(instance.class.as_str(),classname.to_str()?))
})
);
methods.add_meta_function(mlua::MetaMethod::Index,|lua,(this,index):(Self,mlua::String)|{
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|{
let instance=this.get(dom)?;
let instance=dereferent.get(dom)?;
//find a child with a matching name
let maybe_child=instance.children()
.iter()
@ -169,10 +175,11 @@ impl Instance{
}
})
});
methods.add_meta_function(mlua::MetaMethod::NewIndex,|lua,(this,index,value):(Self,mlua::String,mlua::Value)|
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|{
//println!("__newindex t={this:?} i={index:?} v={value:?}");
let instance=this.get_mut(dom)?;
let instance=dereferent.get_mut(dom)?;
//println!("__newindex t={} i={index:?} v={value:?}",instance.name);
let index_str=index.to_str()?;
let db=rbx_reflection_database::get();
let class=db.classes.get(instance.class.as_str()).ok_or(mlua::Error::runtime("Class missing"))?;
@ -198,7 +205,7 @@ impl Instance{
}
Ok(())
})
);
});
}
}