12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #include "la_5.h"
- extern "C" const char* LA_LUA_LIB_COMMON=R"(
- function ddump(tbl, ...)
- log("[dump]")
- if(type(tbl)~='table') then log("Not a table."); return end
- local levels=100
- local dtableonly=0
- local l,d=...
- if(l) then levels=l end
- if(d) then dtableonly=d end
- local checklist = {}
- local function print_kv(indent,k,v,t)
- log(indent..t.." "..k,v,""..(t==' ' and type(v) or ""))
- end
- local function innerdump(tbl,indent,lv)
- local tablelist={}; local funclist={}; local otherlist={}
- checklist[ tostring(tbl) ] = true
- for k,v in pairs(tbl) do
- if type(v)=="function" then funclist[k]={v,'f'}
- elseif type(v)=="table" then tablelist[k]={v,'t'}
- else otherlist[k]={v,' '} end
- end
- for k,v in pairs(tablelist) do
- print_kv(indent,k,v[1],v[2])
- if (lv<levels and not checklist[ tostring(v[1]) ]) then innerdump(v[1],indent.." ",lv+1) end
- end
- if(dtableonly==0) then for k,v in pairs(funclist) do print_kv(indent,k,v[1],v[2]) end end
- if(dtableonly==0) then for k,v in pairs(otherlist) do print_kv(indent,k,v[1],v[2]) end end
- end
- checklist[ tostring(tbl) ] = true
- innerdump( tbl, "", 0)
- end
- function tdump(t)
- ddump(t,100,1)
- end
- ffi = require("ffi")
- )";
|