Skip to content

Commit 538bb50

Browse files
authored
Merge pull request #17 from Krealle/main
Add handling of secret values introduced in 12.0.0
2 parents 4e0e715 + 2123d99 commit 538bb50

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

DevTool.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,16 @@ function DevTool:AddData(data, dataName)
235235
return
236236
end
237237

238+
if issecrettable(data) then
239+
self:Print("Error: The data being added is a secret table. Aborting.")
240+
return
241+
end
242+
243+
if issecretvalue(data) then
244+
self:Print("Error: The data being added is a secret value. Aborting.")
245+
return
246+
end
247+
238248
if not dataName then
239249
dataName = tostring(data)
240250
end
@@ -755,16 +765,17 @@ function DevTool:ProcessCallFunctionData(ok, info, parent, args, results)
755765
-- for example 1, 2, nil, 4 should return only this 4 values nothing more, nothing less.
756766
local found = false
757767
for i = 10, 1, -1 do
758-
if results[i] ~= nil then
768+
local result = DevTool.normalizeSecretValue(results[i])
769+
if result ~= nil then
759770
found = true
760771
end
761772

762773
if found or i == 1 then
763774
-- if found some return or if return is nil
764-
table.insert(elements, self:NewElement(results[i], string.format(" return: %d", i), indentation))
775+
table.insert(elements, self:NewElement(result, string.format(" return: %d", i), indentation))
765776

766-
returnFormattedStr = string.format(" %s (%s)%s", tostring(results[i]),
767-
self.colors.lightblue:WrapTextInColorCode(type(results[i])), returnFormattedStr)
777+
returnFormattedStr = string.format(" %s (%s)%s", tostring(result),
778+
self.colors.lightblue:WrapTextInColorCode(type(result)), returnFormattedStr)
768779
end
769780
end
770781

DevTool.toc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Interface: 11507, 50500, 110200
1+
## Interface: 11507, 50500, 110200, 120000
22
## Title: DevTool
33
## Notes: A multipurpose tool to assist with addon development
44
## IconTexture: Interface\Icons\inv_misc_gear_08
@@ -26,4 +26,4 @@ Modules\FunctionLogger.lua
2626
Modules\History.lua
2727

2828
XML\OptionsFrame.xml
29-
OptionsFrame.lua
29+
OptionsFrame.lua

Utilities/Utils.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ local DevTool = addonTable.DevTool
1010
--- UTILS
1111
-----------------------------------------------------------------------------------------------
1212

13+
function DevTool.normalizeSecretValue(value)
14+
if issecrettable(value) or issecretvalue(value) then
15+
return string.format("<SECRET %s>", type(value))
16+
end
17+
return value
18+
end
19+
1320
--- Math
1421

1522
function DevTool.round(num, idp)
@@ -165,6 +172,7 @@ end
165172

166173
function DevTool.ToUIString(value, name, withoutLineBrakes)
167174
local result
175+
value = DevTool.normalizeSecretValue(value)
168176
local valueType = type(value)
169177

170178
if valueType == "table" then
@@ -188,8 +196,9 @@ function DevTool.GetObjectInfoFromWoWAPI(helperText, value)
188196
-- try to get frame name
189197
if ok then
190198
local concat = function(str, before, after)
191-
before = before or ""
192-
after = after or ""
199+
before = DevTool.normalizeSecretValue(before) or ""
200+
after = DevTool.normalizeSecretValue(after) or ""
201+
str = DevTool.normalizeSecretValue(str)
193202
if str then
194203
return resultStr .. " " .. before .. str .. after
195204
end
@@ -211,6 +220,8 @@ function DevTool.GetObjectInfoFromWoWAPI(helperText, value)
211220
tostring(DevTool.round(height)) .. "]")
212221
end
213222

223+
name = DevTool.normalizeSecretValue(name)
224+
214225
if helperText ~= name then
215226
resultStr = concat(name, DevTool.colors.gray:WrapTextInColorCode("<"), DevTool.colors.gray:WrapTextInColorCode(">"))
216227
end
@@ -284,4 +295,4 @@ function DevTool.GetParentTable(info)
284295
end
285296

286297
return parent
287-
end
298+
end

0 commit comments

Comments
 (0)