summaryrefslogtreecommitdiff
path: root/src/fontloader/misc/fontloader-l-lua.lua
diff options
context:
space:
mode:
authorDavid Carlisle <d.p.carlisle@gmail.com>2015-11-21 21:45:03 +0000
committerDavid Carlisle <d.p.carlisle@gmail.com>2015-11-21 21:45:03 +0000
commitb46f13e0949e310b46e97e791fd4e9e38635a491 (patch)
tree415c893c82e7f55ed630a10033885f1b5781ab56 /src/fontloader/misc/fontloader-l-lua.lua
parenta472b6fd5461318ec1e5d2899af2ef57f0fb14e8 (diff)
parent6c3d70e21b100c6c7ffa11e1c6d9260b32ccc781 (diff)
downloadluaotfload-b46f13e0949e310b46e97e791fd4e9e38635a491.tar.gz
for 2.6
Diffstat (limited to 'src/fontloader/misc/fontloader-l-lua.lua')
-rw-r--r--src/fontloader/misc/fontloader-l-lua.lua34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/fontloader/misc/fontloader-l-lua.lua b/src/fontloader/misc/fontloader-l-lua.lua
index 1a2a987..cb61829 100644
--- a/src/fontloader/misc/fontloader-l-lua.lua
+++ b/src/fontloader/misc/fontloader-l-lua.lua
@@ -129,22 +129,36 @@ local print, select, tostring = print, select, tostring
local inspectors = { }
-function setinspector(inspector) -- global function
- inspectors[#inspectors+1] = inspector
+function setinspector(kind,inspector) -- global function
+ inspectors[kind] = inspector
end
function inspect(...) -- global function
for s=1,select("#",...) do
local value = select(s,...)
- local done = false
- for i=1,#inspectors do
- done = inspectors[i](value)
- if done then
- break
+ if value == nil then
+ print("nil")
+ else
+ local done = false
+ -- type driven (table)
+ local kind = type(value)
+ local inspector = inspectors[kind]
+ if inspector then
+ done = inspector(value)
+ if done then
+ break
+ end
+ end
+ -- whatever driven (token, node, ...)
+ for kind, inspector in next, inspectors do
+ done = inspector(value)
+ if done then
+ break
+ end
+ end
+ if not done then
+ print(tostring(value))
end
- end
- if not done then
- print(tostring(value))
end
end
end