change cf macro to include Instance as the first argument
This commit is contained in:
parent
fac1f318d7
commit
849b0813b9
@ -333,16 +333,20 @@ impl mlua::UserData for Instance{
|
||||
/// A class function definition shorthand.
|
||||
macro_rules! cf{
|
||||
($f:expr)=>{
|
||||
|lua,this|$f(lua,FromLuaMulti::from_lua_multi(this,lua)?)?.into_lua_multi(lua)
|
||||
|lua,args|{
|
||||
//TODO: make this not suck. two fully general conversions? really?
|
||||
let (this,args):(Instance,mlua::MultiValue)=FromLuaMulti::from_lua_multi(args,lua)?;
|
||||
$f(lua,this,FromLuaMulti::from_lua_multi(args,lua)?)?.into_lua_multi(lua)
|
||||
}
|
||||
};
|
||||
}
|
||||
type FPointer=fn(&mlua::Lua,mlua::MultiValue)->mlua::Result<mlua::MultiValue>;
|
||||
type ClassFunctionPointer=fn(&mlua::Lua,mlua::MultiValue)->mlua::Result<mlua::MultiValue>;
|
||||
// TODO: use macros to define these with better organization
|
||||
/// A double hash map of function pointers.
|
||||
/// The class tree is walked by the Instance.__index metamethod to find available class methods.
|
||||
static CLASS_FUNCTION_DATABASE:phf::Map<&str,phf::Map<&str,FPointer>>=phf::phf_map!{
|
||||
static CLASS_FUNCTION_DATABASE:phf::Map<&str,phf::Map<&str,ClassFunctionPointer>>=phf::phf_map!{
|
||||
"DataModel"=>phf::phf_map!{
|
||||
"GetService"=>cf!(|lua,(_this,service):(Instance,mlua::String)|{
|
||||
"GetService"=>cf!(|lua,_this,service:mlua::String|{
|
||||
dom_mut(lua,|dom|{
|
||||
//dom.root_ref()==this.referent ?
|
||||
match &*service.to_str()?{
|
||||
@ -360,7 +364,7 @@ static CLASS_FUNCTION_DATABASE:phf::Map<&str,phf::Map<&str,FPointer>>=phf::phf_m
|
||||
}),
|
||||
},
|
||||
"Terrain"=>phf::phf_map!{
|
||||
"FillBlock"=>cf!(|_lua,_:(Instance,super::cframe::CFrame,Vector3,super::r#enum::Enum)|mlua::Result::Ok(()))
|
||||
"FillBlock"=>cf!(|_lua,_,_:(super::cframe::CFrame,Vector3,super::r#enum::Enum)|mlua::Result::Ok(()))
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user