diff --git a/src/runner/instance.rs b/src/runner/instance.rs index d0d1a77..2129f7c 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -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; +type ClassFunctionPointer=fn(&mlua::Lua,mlua::MultiValue)->mlua::Result; // 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(())) }, };