// Export native function to lua. // - mouguangyi 2016.07.28 public void RegLuaBridgeFunction(LuaBridgeFunction function) { var executer = new LuaExecuter(this, function); LuaLib.LuaPushNumber(luaState, executer.Index); LuaLib.LuaPushCClosure(luaState, LuaExecuter._Execute, 1); LuaLib.LuaSetGlobal(luaState, executer.Name); }
public LuaExecuter(LuaRuntime runtime, LuaBridgeFunction function) { this.runtime = runtime; this.function = function; var attributes = function.GetInvocationList()[0].Method.GetCustomAttributes(typeof(LuaBridgeAttribute), false); if (attributes.Length > 0) { var luaBridgeAttribute = attributes[0] as LuaBridgeAttribute; this.name = luaBridgeAttribute.Name; this.input = luaBridgeAttribute.Input; this.output = luaBridgeAttribute.Output; } else { Logger <ILuaRuntime> .E("The function is missing LuaBridgeAttribute definition!"); } this.index = LuaExecuter.executers.Count; LuaExecuter.executers.Add(this); }