From 481b30f561e58f65733aec918facdfb8fccd325f Mon Sep 17 00:00:00 2001 From: dennygxwang Date: Fri, 13 Dec 2019 15:53:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=AD=E7=82=B9=E8=B0=83=E8=AF=95=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=9F=A5=E7=9C=8B=E5=B8=A6=5F=5Fpairs=E5=85=83?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=9A=84userdata=E7=9A=84=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=8F=98=E9=87=8F=EF=BC=8C=E4=BE=8B=E5=A6=82UE4=E7=9A=84UObjec?= =?UTF-8?q?t=EF=BC=8CUStruct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Debugger/LuaPanda.lua | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/Debugger/LuaPanda.lua b/Debugger/LuaPanda.lua index 385d49a..ca1f4af 100644 --- a/Debugger/LuaPanda.lua +++ b/Debugger/LuaPanda.lua @@ -2042,7 +2042,7 @@ function this.createWatchedVariableInfo(variableName, variableIns) xpcall(function() var.value = tostring(variableIns) end , function() var.value = tostring(type(variableIns)) .. " [value can't trans to string]" end ); var.variablesReference = "0"; --这个地方必须用“0”, 以免variableRefTab[0]出错 - if var.type == "table" or var.type == "function" then + if var.type == "table" or var.type == "function" or var.type == "userdata" then var.variablesReference = variableRefIdx; variableRefTab[variableRefIdx] = variableIns; variableRefIdx = variableRefIdx + 1; @@ -2296,7 +2296,7 @@ function this.getVariableRef( refStr ) var.type = tostring(type(v)); xpcall(function() var.value = tostring(v) end , function() var.value = tostring(type(v)) .. " [value can't trans to string]" end ); var.variablesReference = "0"; - if var.type == "table" or var.type == "function" then + if var.type == "table" or var.type == "function" or var.type == "userdata" then var.variablesReference = variableRefIdx; variableRefTab[variableRefIdx] = v; variableRefIdx = variableRefIdx + 1; @@ -2336,6 +2336,28 @@ function this.getVariableRef( refStr ) variableRefTab[variableRefIdx] = udMtTable; variableRefIdx = variableRefIdx + 1; table.insert(varTab, var); + + if udMtTable.__pairs ~= nil and type(udMtTable.__pairs) == "function" then + for n,v in pairs(variableRefTab[varRef]) do + local var = {}; + var.name = tostring(n); + var.type = tostring(type(v)); + xpcall(function() var.value = tostring(v) end , function() var.value = tostring(type(v)) .. " [value can't trans to string]" end ); + var.variablesReference = "0"; + if var.type == "table" or var.type == "function" or var.type == "userdata" then + var.variablesReference = variableRefIdx; + variableRefTab[variableRefIdx] = v; + variableRefIdx = variableRefIdx + 1; + if var.type == "table" then + local memberNum = this.getTableMemberNum(v); + var.value = memberNum .." Members ".. ( var.value or '' ); + end + elseif var.type == "string" then + var.value = '"' ..v.. '"'; + end + table.insert(varTab, var); + end + end end end return varTab; @@ -2352,7 +2374,7 @@ function this.getGlobalVariable( ... ) var.type = tostring(type(v)); xpcall(function() var.value = tostring(v) end , function() var.value = tostring(type(v)) .." [value can't trans to string]" end ); var.variablesReference = "0"; - if var.type == "table" or var.type == "function" then + if var.type == "table" or var.type == "function" or var.type == "userdata" then var.variablesReference = variableRefIdx; variableRefTab[variableRefIdx] = v; variableRefIdx = variableRefIdx + 1; @@ -2395,7 +2417,7 @@ function this.getUpValueVariable( checkFunc , isFormatVariable) if isGetValue == false then xpcall(function() var.value = tostring(v) end , function() var.value = tostring(type(v)) .. " [value can't trans to string]" end ); - if var.type == "table" or var.type == "function" then + if var.type == "table" or var.type == "function" or var.type == "userdata" then var.variablesReference = variableRefIdx; variableRefTab[variableRefIdx] = v; variableRefIdx = variableRefIdx + 1; @@ -2457,7 +2479,7 @@ function this.getVariable( checkLayer, isFormatVariable , offset) if isGetValue == false then xpcall(function() var.value = tostring(v) end , function() var.value = tostring(type(v)) .. " [value can't trans to string]" end ); - if var.type == "table" or var.type == "function" then + if var.type == "table" or var.type == "function" or var.type == "userdata" then var.variablesReference = variableRefIdx; variableRefTab[variableRefIdx] = v; variableRefIdx = variableRefIdx + 1; @@ -2530,7 +2552,7 @@ function this.processExp(msgTable) var.type = tostring(type(retString)); xpcall(function() var.value = tostring(retString) end , function(e) var.value = tostring(type(retString)) .. " [value can't trans to string] ".. e; var.isSuccess = false; end); var.variablesReference = "0"; - if var.type == "table" or var.type == "function" then + if var.type == "table" or var.type == "function" or var.type == "userdata" then variableRefTab[variableRefIdx] = retString; var.variablesReference = variableRefIdx; variableRefIdx = variableRefIdx + 1; @@ -2575,7 +2597,7 @@ function this.processWatchedExp(msgTable) xpcall(function() var.value = tostring(retString) end , function() var.value = tostring(type(retString)) .. " [value can't trans to string]"; var.isSuccess = "false"; end ); var.variablesReference = "0"; - if var.type == "table" or var.type == "function" then + if var.type == "table" or var.type == "function" or var.type == "userdata" then variableRefTab[variableRefIdx] = retString; var.variablesReference = variableRefIdx; variableRefIdx = variableRefIdx + 1;