rename ClassFunctions -> ClassMethodsStore
This commit is contained in:
parent
210832c737
commit
a6eb5e184c
@ -8,7 +8,7 @@ use super::vector3::Vector3;
|
|||||||
|
|
||||||
pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table)->Result<(),mlua::Error>{
|
pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table)->Result<(),mlua::Error>{
|
||||||
//class functions store
|
//class functions store
|
||||||
lua.set_app_data(ClassFunctions::default());
|
lua.set_app_data(ClassMethodsStore::default());
|
||||||
|
|
||||||
let instance_table=lua.create_table()?;
|
let instance_table=lua.create_table()?;
|
||||||
|
|
||||||
@ -34,10 +34,6 @@ fn dom_mut<T>(lua:&mlua::Lua,mut f:impl FnMut(&mut WeakDom)->mlua::Result<T>)->m
|
|||||||
let mut dom=lua.app_data_mut::<&'static mut WeakDom>().ok_or(mlua::Error::runtime("DataModel missing"))?;
|
let mut dom=lua.app_data_mut::<&'static mut WeakDom>().ok_or(mlua::Error::runtime("DataModel missing"))?;
|
||||||
f(&mut *dom)
|
f(&mut *dom)
|
||||||
}
|
}
|
||||||
fn class_functions_mut<T>(lua:&mlua::Lua,mut f:impl FnMut(&mut ClassFunctions)->mlua::Result<T>)->mlua::Result<T>{
|
|
||||||
let mut cf=lua.app_data_mut::<ClassFunctions>().ok_or(mlua::Error::runtime("ClassFunctions missing"))?;
|
|
||||||
f(&mut *cf)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn coerce_float32(value:&mlua::Value)->Option<f32>{
|
fn coerce_float32(value:&mlua::Value)->Option<f32>{
|
||||||
match value{
|
match value{
|
||||||
@ -262,7 +258,7 @@ impl mlua::UserData for Instance{
|
|||||||
other=>return Err(mlua::Error::runtime(format!("Instance.__index Unsupported property type instance={} index={index_str} value={other:?}",instance.name))),
|
other=>return Err(mlua::Error::runtime(format!("Instance.__index Unsupported property type instance={} index={index_str} value={other:?}",instance.name))),
|
||||||
}
|
}
|
||||||
//find a function with a matching name
|
//find a function with a matching name
|
||||||
if let Some(function)=class_functions_mut(lua,|cf|{
|
if let Some(function)=class_methods_store_mut(lua,|cf|{
|
||||||
let mut iter=SuperClassIter{
|
let mut iter=SuperClassIter{
|
||||||
database:db,
|
database:db,
|
||||||
descriptor:Some(class),
|
descriptor:Some(class),
|
||||||
@ -391,14 +387,14 @@ static CLASS_FUNCTION_DATABASE:CFD=phf::phf_map!{
|
|||||||
/// A store of created functions for each Roblox class.
|
/// A store of created functions for each Roblox class.
|
||||||
/// Functions are created the first time they are accessed and stored in this data structure.
|
/// Functions are created the first time they are accessed and stored in this data structure.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ClassFunctions{
|
struct ClassMethodsStore{
|
||||||
classes:HashMap<&'static str,//ClassName
|
classes:HashMap<&'static str,//ClassName
|
||||||
HashMap<&'static str,//Method name
|
HashMap<&'static str,//Method name
|
||||||
mlua::Function
|
mlua::Function
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
impl ClassFunctions{
|
impl ClassMethodsStore{
|
||||||
/// return self.classes[class] or create the ClassMethods and then return it
|
/// return self.classes[class] or create the ClassMethods and then return it
|
||||||
fn get_or_create_class_methods(&mut self,class:&str)->Option<ClassMethods>{
|
fn get_or_create_class_methods(&mut self,class:&str)->Option<ClassMethods>{
|
||||||
// Use get_entry to get the &'static str keys of the database
|
// Use get_entry to get the &'static str keys of the database
|
||||||
@ -433,6 +429,10 @@ impl ClassMethods<'_>{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn class_methods_store_mut<T>(lua:&mlua::Lua,mut f:impl FnMut(&mut ClassMethodsStore)->mlua::Result<T>)->mlua::Result<T>{
|
||||||
|
let mut cf=lua.app_data_mut::<ClassMethodsStore>().ok_or(mlua::Error::runtime("ClassMethodsStore missing"))?;
|
||||||
|
f(&mut *cf)
|
||||||
|
}
|
||||||
|
|
||||||
/// A virtual property pointer definition shorthand.
|
/// A virtual property pointer definition shorthand.
|
||||||
type VirtualPropertyFunctionPointer=fn(&rbx_types::Variant)->Option<rbx_types::Variant>;
|
type VirtualPropertyFunctionPointer=fn(&rbx_types::Variant)->Option<rbx_types::Variant>;
|
||||||
|
Loading…
Reference in New Issue
Block a user