Debugging watch window where __type has been set [message #898682] |
Fri, 27 July 2012 08:10 |
Richard Geary Messages: 14 Registered: July 2012 |
Junior Member |
|
|
I'm trying to debug some 3rd party Lua code, where they have set the __type metafield for a table. The Koneki debugger's watch window shows this value as "table: 0xc40520", rather than table[10], and I lose the ability to see what's inside the table.
Can I fix this so the watch window looks at the builtin type to decide how to display it? Where in the codebase would I look?
Thanks!
Update :
The 3rd party code is overriding the built-in type function to retrieve the __type metadata field, so the problem is just the debug watch window doesn't handle it well.
--
-- An extension to type() to identify project object types by reading the
-- "__type" field from the metatable.
--
local builtin_type = type
function type(t)
local mt = getmetatable(t)
if (mt) then
if (mt.__type) then
return mt.__type
end
end
return builtin_type(t)
end
To repro, add the above plus :
local obj = {}
obj.x = 2
setmetatable( obj, { __type="blah" })
-- Set a breakpoint here, obj is table : 0xsomething in watch window
local typeofObj = type(obj)
-- But typeofObj is correctly "blah" in watch window
[Updated on: Mon, 30 July 2012 08:18] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04352 seconds