You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is very long and hard to read. However, with some edits to inspect.lua I was able to get this:
<TileMapLayer>{
tiles = {
["0,0"] = <Tile>{
id = 0,
tid = 4
},
["0,1"] = <Tile>{
id = 1,
tid = 4
},
...
}
This is much easier to read and more useful for simple printf debugging. :)
Here's the diff:
@@ -163,7 +163,8 @@ local function getKeys(t)
local keys, keysLen = {}, 0
for k in rawpairs(t) do
- if not isSequenceKey(k, seqLen) then+ -- Elias Daler EDIT: don't print "class" table+ if not isSequenceKey(k, seqLen) and k ~= "class" then
keysLen = keysLen + 1
keys[keysLen] = k
end
@@ -273,6 +274,11 @@ function Inspector:putValue(v)
elseif tv == 'table' and not self.ids[v] then
local t = v
+ -- Elias Daler EDIT: print middleclass instance name+ if type(t.class) == "table" then -- metaclass obj instatnce+ puts(buf, "<" .. t.class.name .. ">")+ end+
if t == inspect.KEY or t == inspect.METATABLE then
puts(buf, tostring(t))
elseif self.level >= self.depth then
@@ -305,13 +311,14 @@ function Inspector:putValue(v)
end
end
- local mt = getmetatable(t)+ -- Elias Daler EDIT: don't print metatables+ --[[ local mt = getmetatable(t)
if type(mt) == 'table' then
if seqLen + keysLen > 0 then puts(buf, ',') end
tabify(self)
puts(buf, '<metatable> = ')
self:putValue(mt)
- end+ end ]]--
self.level = self.level - 1
Obviously, this functionality should be optional and configurable by options. But what do you think about it?
Maybe it's worth making some option like "middleclass_simple_print" or something?
The text was updated successfully, but these errors were encountered:
Maybe not exactly what you might need, but I have a middleclass-using object in which I add the following mixin:
-- An "inspect" function on the instance that only prints its data.Inspectable= {
inspect=function(self)
localfunctiononly_inspect_data(item, path)
ifpath[#path] ~=inspect.METATABLEandpath[#path] ~='class' andtype(item) ~='function'thenreturnitemendendreturninspect(self, {process=only_inspect_data})
end
}
It's enough for my use case, as it just prints the values with data, which is exactly what I need in my case. It will do the same as 2 of your changes without having to patch inspect.lua. It would need extra work in order to do the printing of the class name in brackets, though, and I think that is not possible without changing the library.
Hello.
I've been using middleclass and inspect for a long time, but today I came up with idea and want to hear your feedback :)
Currently, if you use a complex middleclass type with inspect, you get something like this:
This is very long and hard to read. However, with some edits to inspect.lua I was able to get this:
This is much easier to read and more useful for simple printf debugging. :)
Here's the diff:
Obviously, this functionality should be optional and configurable by options. But what do you think about it?
Maybe it's worth making some option like "middleclass_simple_print" or something?
The text was updated successfully, but these errors were encountered: