/// <summary> /// Activates the debug hook /// </summary> /// <param name="mask">Mask</param> /// <param name="count">Count</param> /// <returns>see lua docs. -1 if hook is already set</returns> /// <author>Reinhard Ostermeier</author> public int SetDebugHook(EventMasks mask, int count) { if (hookCallback == null) { hookCallback = new LuaHookFunction(DebugHookCallback); return(LuaDLL.lua_sethook(luaState, hookCallback, (int)mask, count)); } return(-1); }
public static IntPtr ToFunctionPointer(this LuaHookFunction d) { if (d == null) { return(IntPtr.Zero); } return(Marshal.GetFunctionPointerForDelegate <LuaHookFunction>(d)); }
/* * Lets go of a previously allocated reference to a table, function * or userdata */ #region lua debug functions /// <summary> /// Activates the debug hook /// </summary> /// <param name = "mask">Mask</param> /// <param name = "count">Count</param> /// <returns>see lua docs. -1 if hook is already set</returns> public int SetDebugHook(LuaHookMask mask, int count) { if (hookCallback == null) { hookCallback = new LuaHookFunction(Lua.DebugHookCallback); luaState.SetHook(hookCallback, mask, count); } return(-1); }
/* * Lets go of a previously allocated reference to a table, function * or userdata */ #region lua debug functions /// <summary> /// Activates the debug hook /// </summary> /// <param name = "mask">Mask</param> /// <param name = "count">Count</param> /// <returns>see lua docs. -1 if hook is already set</returns> public int SetDebugHook(LuaHookMask mask, int count) { if (_hookCallback == null) { _hookCallback = DebugHookCallback; _luaState.SetHook(_hookCallback, mask, count); } return(-1); }
public static IntPtr ToFunctionPointer(this LuaHookFunction d) { if (d == null) { return(IntPtr.Zero); } #if NETFRAMEWORK return(Marshal.GetFunctionPointerForDelegate(d)); #else return(Marshal.GetFunctionPointerForDelegate <LuaHookFunction>(d)); #endif }
public void TestLuaHookStruct() { FuncHookCallback = HookCalbackStruct; var state = new Lua(); hookLog = new StringBuilder(); state.SetHook(FuncHookCallback, LuaHookMask.Line, 0); Assert.AreEqual(FuncHookCallback, state.Hook, "#1"); state.DoFile("main.lua"); string output = hookLog.ToString(); string expected = @"main.lua-main.lua:2 (main) ./foo.lua-foo.lua:2 (main) ./module1.lua-module1.lua:3 (main) ./module1.lua-module1.lua:9 (main) ./module1.lua-module1.lua:5 (main) ./module1.lua-module1.lua:11 (main) ./foo.lua-foo.lua:8 (main) ./foo.lua-foo.lua:4 (main) ./foo.lua-foo.lua:14 (main) ./foo.lua-foo.lua:10 (main) ./foo.lua-foo.lua:14 (main) main.lua-main.lua:4 (main) main.lua-main.lua:5 (main) main.lua-main.lua:7 (main) main.lua-main.lua:8 (main) ./foo.lua-foo.lua:5 (Lua) ./foo.lua-foo.lua:6 (Lua) ./foo.lua-foo.lua:7 (Lua) ./module1.lua-module1.lua:6 (Lua) ./module1.lua-module1.lua:7 (Lua) ./module1.lua-module1.lua:8 (Lua) ./foo.lua-foo.lua:8 (Lua) main.lua-main.lua:11 (main) "; expected = expected.Replace('/', System.IO.Path.DirectorySeparatorChar); expected = expected.Replace("\r", ""); output = output.Replace("\r", ""); Assert.AreEqual(expected, output, "#2"); state.SetHook(FuncHookCallback, LuaHookMask.Disabled, 0); Assert.IsNull(state.Hook, "#3"); }
/// <summary> /// Removes the debug hook /// </summary> /// <returns>see lua docs</returns> /// <author>Reinhard Ostermeier</author> public int RemoveDebugHook() { hookCallback = null; return(LuaDLL.lua_sethook(luaState, null, 0, 0)); }
public int SetDebugHook(EventMasks mask, int count) { if (this.hookCallback == null) { this.hookCallback = new LuaHookFunction(this.DebugHookCallback); return LuaJIT.lua_sethook(this.luaState, this.hookCallback, (int) mask, count); } return -1; }
public int RemoveDebugHook() { this.hookCallback = null; return LuaJIT.lua_sethook(this.luaState, null, 0, 0); }
/// <summary> /// Removes the debug hook /// </summary> /// <returns>see lua docs</returns> /// <author>Reinhard Ostermeier</author> public int RemoveDebugHook() { hookCallback = null; return LuaDLL.lua_sethook(luaState, null, 0, 0); }
/// <summary> /// Activates the debug hook /// </summary> /// <param name="mask">Mask</param> /// <param name="count">Count</param> /// <returns>see lua docs. -1 if hook is already set</returns> /// <author>Reinhard Ostermeier</author> public int SetDebugHook(EventMasks mask, int count) { if (hookCallback == null) { hookCallback = new LuaHookFunction(DebugHookCallback); return LuaDLL.lua_sethook(luaState, hookCallback, (int)mask, count); } return -1; }
/// <summary> /// Removes the debug hook /// </summary> /// <returns>see lua docs</returns> public void RemoveDebugHook() { hookCallback = null; luaState.SetHook(null, LuaHookMask.Disabled, 0); }
public static extern int lua_sethook(lua_StatePtr L, LuaHookFunction func, int mask, int count);
public static extern int lua_sethook(IntPtr luaState, LuaHookFunction f, LuaHookMasks mask, int count);