/* ** this function can be called asynchronous (e.g. during a signal) */ public static int LuaSetHook (LuaState L, LuaHook func, int mask, int count) { if (func == null || mask == 0) { /* turn off hooks? */ mask = 0; func = null; } L.hook = func; L.basehookcount = count; ResetHookCount(L); L.hookmask = CastByte(mask); return 1; }
/* ** this function can be called asynchronous (e.g. during a signal) */ public static int LuaSetHook(LuaState L, LuaHook func, int mask, int count) { if (func == null || mask == 0) /* turn off hooks? */ { mask = 0; func = null; } L.hook = func; L.basehookcount = count; ResetHookCount(L); L.hookmask = CastByte(mask); return(1); }
private static int DBGetHook(LuaState L) { int arg; LuaState L1 = GetThread(L, out arg); CharPtr buff = new char[5]; int mask = LuaGetHookMask(L1); LuaHook hook = LuaGetHook(L1); if (hook != null && hook != HookF) /* external hook? */ { LuaPushLiteral(L, "external hook"); } else { GetHookTable(L); LuaPushLightUserData(L, L1); LuaRawGet(L, -2); /* get hook */ LuaRemove(L, -2); /* remove hook table */ } LuaPushString(L, UnmakeMask(mask, buff)); LuaPushInteger(L, LuaGetHookCount(L1)); return(3); }
/* * 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> /// <author>Reinhard Ostermeier</author> public int SetDebugHook (EventMasks mask, int count) { if (hookCallback == null) { hookCallback = new LuaHook (Lua.DebugHookCallback); return LuaCore.LuaSetHook (luaState, hookCallback, (int)mask, count); } return -1; }
public static extern int lua_sethook(IntPtr L, LuaHook func, int mask, int count);
/// <summary> /// Removes the debug hook /// </summary> /// <returns>see lua docs</returns> public int RemoveDebugHook() { hookCallback = null; return(LuaCore.LuaSetHook(luaState, null, 0, 0)); }
public LuaSetup() { PrintMessage("Lua!"); LuaScriptLoader luaScriptLoader = new LuaScriptLoader(this); LuaCustomConverters.RegisterAll(); UserData.RegisterType <TraitorMessageType>(); UserData.RegisterType <JobPrefab>(); UserData.RegisterType <CharacterInfo>(); UserData.RegisterType <Rectangle>(); UserData.RegisterType <Point>(); UserData.RegisterType <Level.InterestingPosition>(); UserData.RegisterType <Level.PositionType>(); UserData.RegisterType <Level>(); UserData.RegisterType <Items.Components.Steering>(); UserData.RegisterType <ServerLog.MessageType>(); UserData.RegisterType <SpawnType>(); UserData.RegisterType <ChatMessageType>(); UserData.RegisterType <WayPoint>(); UserData.RegisterType <Character>(); UserData.RegisterType <Item>(); UserData.RegisterType <Submarine>(); UserData.RegisterType <Client>(); UserData.RegisterType <LuaPlayer>(); UserData.RegisterType <LuaHook>(); UserData.RegisterType <LuaGame>(); UserData.RegisterType <LuaRandom>(); UserData.RegisterType <LuaTimer>(); UserData.RegisterType <Vector2>(); UserData.RegisterType <Vector3>(); UserData.RegisterType <Vector4>(); lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.LoadMethods); lua.Options.DebugPrint = PrintMessage; lua.Options.ScriptLoader = luaScriptLoader; hook = new LuaHook(this); game = new LuaGame(this); lua.Globals["Player"] = new LuaPlayer(); lua.Globals["Game"] = game; lua.Globals["Hook"] = hook; lua.Globals["Random"] = new LuaRandom(); lua.Globals["Timer"] = new LuaTimer(this); lua.Globals["WayPoint"] = UserData.CreateStatic <WayPoint>(); lua.Globals["SpawnType"] = UserData.CreateStatic <SpawnType>(); lua.Globals["ChatMessageType"] = UserData.CreateStatic <ChatMessageType>(); lua.Globals["ServerLog_MessageType"] = UserData.CreateStatic <ServerLog.MessageType>(); lua.Globals["Submarine"] = UserData.CreateStatic <Submarine>(); lua.Globals["Client"] = UserData.CreateStatic <Client>(); lua.Globals["Character"] = UserData.CreateStatic <Character>(); lua.Globals["Item"] = UserData.CreateStatic <Item>(); lua.Globals["Level"] = UserData.CreateStatic <Level>(); lua.Globals["Vector2"] = UserData.CreateStatic <Vector2>(); lua.Globals["Vector3"] = UserData.CreateStatic <Vector3>(); lua.Globals["PositionType"] = UserData.CreateStatic <Level.PositionType>(); lua.Globals["JobPrefab"] = UserData.CreateStatic <JobPrefab>(); lua.Globals["TraitorMessageType"] = UserData.CreateStatic <TraitorMessageType>(); foreach (string d in Directory.GetDirectories("Lua")) { if (Directory.Exists(d + "/autorun")) { luaScriptLoader.RunFolder(d + "/autorun"); } } }
public static int SetHook(LuaStatePtr l, LuaHook func, int mask, int count) { return(LuaDelegates.lua_sethook(l, func, mask, count)); }
internal static extern int lua_sethook(LuaStatePtr l, LuaHook func, int mask, int count);
public int LuaSetHook(LuaHook func, int mask, int count) { return(LuaDLL.lua_sethook(L, func, mask, count)); }
/// <summary> /// Sets the debugging hook function. /// </summary> public void SetHook(LuaHook func, LuaHookMask mask, int count) { throw new NotImplementedException(); }
void DoToolbar() { var setting = LuaDeepProfilerSetting.Instance; #region profiler settting GUILayout.Label("profiler setting"); GUILayout.BeginVertical("Box"); EditorGUILayout.BeginHorizontal(); bool flag = GUILayout.Toggle(setting.isDeepLuaProfiler, "Deep Profiler Lua"); if (flag != setting.isDeepLuaProfiler) { setting.isDeepLuaProfiler = flag; if (!flag) { setting.isCleanMode = false; } EditorApplication.isPlaying = false; } flag = GUILayout.Toggle(setting.isDeepMonoProfiler, "Deep Profiler Mono"); if (flag != setting.isDeepMonoProfiler) { setting.isDeepMonoProfiler = flag; EditorApplication.isPlaying = false; InjectMethods.Recompile(); } flag = GUILayout.Toggle(setting.discardInvalid, "Discard Invalid"); if (flag != setting.discardInvalid) { setting.discardInvalid = flag; } flag = GUILayout.Toggle(setting.isCleanMode, "PreCompile Lua(Use InjectLua.exe)"); if (flag != setting.isCleanMode) { setting.isCleanMode = flag; if (setting.isCleanMode) { setting.isDeepLuaProfiler = true; } EditorApplication.isPlaying = false; } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); if (GUILayout.Button("ReCompile", GUILayout.Height(50))) { InjectMethods.Recompile(); } GUILayout.Space(5); GUILayout.EndVertical(); #endregion #region socket GUILayout.Space(10); GUILayout.Label("connet"); GUILayout.BeginVertical("Box"); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); GUILayout.Label("ip:", GUILayout.Height(30), GUILayout.Width(35)); setting.ip = EditorGUILayout.TextField(setting.ip, GUILayout.Height(16), GUILayout.Width(100)); GUILayout.Label("port:", GUILayout.Height(30), GUILayout.Width(35)); setting.port = EditorGUILayout.IntField(setting.port, GUILayout.Height(16), GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); /* * if (GUILayout.Button("Connent", GUILayout.Height(50))) * { * NetWorkClient.ConnectServer(setting.ip, setting.port); * } * GUILayout.Space(5);*/ GUILayout.EndVertical(); #endregion #region diff GUILayout.BeginVertical("Box"); GUILayout.Space(5); GUILayout.BeginHorizontal(); #if (UNITY_5 || UNITY_2017_1_OR_NEWER) if (GUILayout.Button("MarkLuaRecord", GUILayout.Height(30))) { LuaHook.Record(); m_luaDiffScrollView.MarkIsRecord(); } if (GUILayout.Button("DiffRecord", GUILayout.Height(30))) { m_luaDiffScrollView.DelDiffInfo(LuaHook.Diff()); } if (GUILayout.Button("ClearDiff", GUILayout.Height(30))) { m_luaDiffScrollView.Clear(); } GUILayout.EndHorizontal(); m_luaDiffScrollView.DoRefScroll(); #endif GUILayout.EndVertical(); #endregion #region capture /* * GUILayout.Space(10); * * GUILayout.Label("capture setting"); * GUILayout.BeginVertical("Box"); * * flag = GUILayout.Toggle(LuaDeepProfilerSetting.Instance.isNeedCapture, "NeedCapture"); * if (flag != LuaDeepProfilerSetting.Instance.isNeedCapture) * { * LuaDeepProfilerSetting.Instance.isNeedCapture = flag; * if (flag) * { * GameViewUtility.ChangeGameViewSize(480, 270); * } * } * * GUILayout.Space(10); * * EditorGUILayout.BeginHorizontal(); * GUILayout.Label("lua gc", GUILayout.Height(30), GUILayout.Width(45)); * LuaDeepProfilerSetting.Instance.captureLuaGC * = EditorGUILayout.IntField(LuaDeepProfilerSetting.Instance.captureLuaGC, GUILayout.Height(16), GUILayout.Width(50)); * LuaDeepProfilerSetting.Instance.captureLuaGC = Mathf.Max(0, LuaDeepProfilerSetting.Instance.captureLuaGC); * GUILayout.Label("B", GUILayout.Height(30), GUILayout.Width(20)); * * GUILayout.Label("mono gc", GUILayout.Height(30), GUILayout.Width(55)); * LuaDeepProfilerSetting.Instance.captureMonoGC * = EditorGUILayout.IntField(LuaDeepProfilerSetting.Instance.captureMonoGC, GUILayout.Height(16), GUILayout.Width(50)); * LuaDeepProfilerSetting.Instance.captureMonoGC = Mathf.Max(0, LuaDeepProfilerSetting.Instance.captureMonoGC); * GUILayout.Label("B", GUILayout.Height(30), GUILayout.Width(20)); * * GUILayout.Label("capture ", GUILayout.Height(30), GUILayout.Width(50)); * LuaDeepProfilerSetting.Instance.captureFrameRate * = EditorGUILayout.IntField(LuaDeepProfilerSetting.Instance.captureFrameRate, GUILayout.Height(16), GUILayout.Width(50)); * LuaDeepProfilerSetting.Instance.captureFrameRate = Mathf.Max(0, LuaDeepProfilerSetting.Instance.captureFrameRate); * GUILayout.Label("FPS", GUILayout.Height(30), GUILayout.Width(30)); * * EditorGUILayout.EndHorizontal(); * * GUILayout.EndVertical(); */ #endregion }
/// <summary> /// Removes the debug hook /// </summary> /// <returns>see lua docs</returns> /// <author>Reinhard Ostermeier</author> public int RemoveDebugHook () { hookCallback = null; return LuaCore.LuaSetHook (luaState, null, 0, 0); }
public static int LuaSetHook (IntPtr luaState, LuaHook func, int mask, int count) { IntPtr funcHook = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate (func); return NativeMethods.LuaSetHook (luaState, funcHook, mask, count); }
public static int LuaSetHook(IntPtr luaState, LuaHook func, int mask, int count) { IntPtr funcHook = Marshal.GetFunctionPointerForDelegate(func); return(NativeMethods.LuaSetHook(luaState, funcHook, mask, count)); }