static int HandleError(IntPtr L) { string error = LPLuaHook.GetRefString(L, 1); Debug.LogError(error); return(0); }
private static void SetTable(int refIndex, Dictionary <LuaTypes, HashSet <string> > dict, Dictionary <string, List <string> > detailDict) { IntPtr L = LPLuaProfiler.mainL; if (L == IntPtr.Zero) { return; } dict.Clear(); int oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_getref(L, refIndex); if (LuaDLL.lua_type(L, -1) != LuaTypes.LUA_TTABLE) { LuaDLL.lua_pop(L, 1); return; } int t = oldTop + 1; LuaDLL.lua_pushnil(L); /* 第一个 key */ while (LuaDLL.lua_next(L, t) != 0) { /* 用一下 'key' (在索引 -2 处) 和 'value' (在索引 -1 处) */ int key_t = LuaDLL.lua_gettop(L); LuaDLL.lua_pushnil(L); /* 第一个 key */ string firstKey = null; List <string> detailList = new List <string>(); while (LuaDLL.lua_next(L, key_t) != 0) { string key = LPLuaHook.GetRefString(L, -1); if (string.IsNullOrEmpty(firstKey)) { firstKey = key; } detailList.Add(key); LuaDLL.lua_pop(L, 1); } LuaDLL.lua_settop(L, key_t); if (!string.IsNullOrEmpty(firstKey)) { HashSet <string> list; LuaTypes luaType = (LuaTypes)LuaDLL.lua_type(L, -2); if (!dict.TryGetValue(luaType, out list)) { list = new HashSet <string>(); dict.Add(luaType, list); } if (!list.Contains(firstKey)) { list.Add(firstKey); } detailDict[firstKey] = detailList; } /* 移除 'value' ;保留 'key' 做下一次迭代 */ LuaDLL.lua_pop(L, 1); } LuaDLL.lua_settop(L, oldTop); }
static int RemoveRefFunInfo(IntPtr L) { string funName = LPLuaHook.GetRefString(L, 1); string funAddr = LPLuaHook.GetRefString(L, 2); byte type = (byte)LuaDLL.lua_tonumber(L, 3); LPLuaProfiler.RemoveRef(funName, funAddr, type); return(0); }
static int BeginSampleCustom(IntPtr L) { LPLuaProfiler.BeginSample(L, LPLuaHook.GetRefString(L, 1), true); return(0); }