debug lib bugfix
This commit is contained in:
+17
-15
@@ -1,18 +1,31 @@
|
|||||||
local function print(msg)
|
local format_key, format_value, print, print_pair, print_table
|
||||||
|
|
||||||
|
function print(msg)
|
||||||
DEFAULT_CHAT_FRAME:AddMessage(msg, 1, 0, 0)
|
DEFAULT_CHAT_FRAME:AddMessage(msg, 1, 0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function format_key(k)
|
function format_key(k)
|
||||||
return type(k) == 'string' and k or '[' .. tostring(k) .. ']'
|
return type(k) == 'string' and k or '[' .. tostring(k) .. ']'
|
||||||
end
|
end
|
||||||
|
|
||||||
local function format_value(v)
|
function format_value(v)
|
||||||
return type(v) == 'string' and '"' .. v .. '"' or tostring(v)
|
return type(v) == 'string' and '"' .. v .. '"' or tostring(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function print_table(t, depth)
|
||||||
|
for i = 1, getn(t) do
|
||||||
|
print_pair(i, t[i], depth)
|
||||||
|
end
|
||||||
|
for k, v in t do
|
||||||
|
if type(k) ~= 'number' or k < 1 or k > getn(t) then
|
||||||
|
print_pair(k, v, depth)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local max_depth
|
local max_depth
|
||||||
|
|
||||||
local function print_pair(k, v, depth)
|
function print_pair(k, v, depth)
|
||||||
local padding = strrep(' ', depth * 4)
|
local padding = strrep(' ', depth * 4)
|
||||||
if depth == max_depth then
|
if depth == max_depth then
|
||||||
print(padding .. '...')
|
print(padding .. '...')
|
||||||
@@ -26,17 +39,6 @@ local function print_pair(k, v, depth)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function print_table(t, depth)
|
|
||||||
for i = 1, getn(t) do
|
|
||||||
print_pair(i, t[i], depth)
|
|
||||||
end
|
|
||||||
for k, v in t do
|
|
||||||
if type(k) ~= 'number' or k < 1 or k > getn(t) then
|
|
||||||
print_pair(k, v, depth)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function inspect(_, ...)
|
function inspect(_, ...)
|
||||||
local n = arg.n
|
local n = arg.n
|
||||||
arg.n = nil
|
arg.n = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user